Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,244
    • Issues 5,244
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 568
    • Merge requests 568
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #2569
Closed
Open
Issue created Sep 07, 2008 by ajd@trac-ajd

Inferred type not accepted by compiler

ghc --version: The Glorious Glasgow Haskell Compilation System, version 6.9.20080825

A.hs:

{-# LANGUAGE TypeFamilies #-}

module A
  where

data H a = A a | B a deriving Eq

class PL p

class PE a where
  type P a :: *

instance PE [a] where
  type P [a] = H a

instance PL (H a)

foo :: PE a => [P a] -> [P a] -> (([P a], [P a]),([P a],[P a]))
foo pa pb = ((pa, pa), (pb, pb))

-- bar :: (PE a) => [P a] -> [P a] -> Either ([P a], [P a]) [P a]
bar pa pb
  = let _ = foo pa pb
    in case True of
         True -> Right pa
         False -> Left (pa, pb)

Load the above module into GHCi.

*A> :t bar
bar :: (PE a) => [P a] -> [P a] -> Either ([P a], [P a]) [P a]

However, if we uncomment bar's type signature (which is exactly the same as the one printed by GHCi), we get a type error:

[1 of 1] Compiling A                ( A.hs, interpreted )

A.hs:23:16:
    Couldn't match expected type `P a' against inferred type `P a1'
      Expected type: [P a]
      Inferred type: [P a1]
    In the first argument of `foo', namely `pa'
    In the expression: foo pa pb
Failed, modules loaded: none.

I'm not all that familiar with type families, but I'm pretty sure that when GHCi prints a type, we ought to be able to specify that type and the module ought to compile...

Trac metadata
Trac field Value
Version 6.9
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system Unknown
Architecture Unknown
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking