[GHC] #11623: Wrong error message for type family definition that is wrong in multiple ways
GHC
ghc-devs at haskell.org
Sun Feb 21 19:24:34 UTC 2016
#11623: Wrong error message for type family definition that is wrong in multiple
ways
-------------------------------------+-------------------------------------
Reporter: rwbarton | Owner:
Type: bug | Status: new
Priority: low | Milestone:
Component: Compiler | Version: 8.1
(Type checker) |
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: Other
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
{{{
GHCi, version 8.1.20160212: http://www.haskell.org/ghc/ :? for help
Prelude> :set -XTypeFamilies
Prelude> type family T where { Maybe T = Int }
<interactive>:2:23: error:
• Too many parameters to T:
T is unexpected;
expected only no parameters
• In the type family declaration for ‘T’
}}}
This error message is wrong ("Too many parameters to `T`").
Seems like GHC checks whether the equation `Maybe T = Int` has the right
number of arguments before it checks whether it is actually headed by `T`.
Then the error message is worded in a way that assumes the instance head
actually was `T`.
The 7.10 error message was better in this regard:
{{{
<interactive>:3:23:
Number of parameters must match family declaration; expected 0
In the type family declaration for ‘T’
}}}
but it would be even better to generate the error below (that is generated
once the number of arguments is correct) for the original program:
{{{
Prelude> type family T a where { Maybe (T ()) = Int }
<interactive>:5:25: error:
• Mismatched type name in type family instance.
Expected: T
Actual: Maybe
• In the type family declaration for ‘T’
}}}
We should generate that error before kind-checking the definition too.
I don't really understand the difference between these two cases though,
so maybe my guess is wrong.
{{{
Prelude> type family T where { T () = Int }
<interactive>:10:23: error:
• Too many parameters to T:
() is unexpected;
expected only no parameters
• In the type family declaration for ‘T’
Prelude> type family T :: * -> * where { T () = Int }
<interactive>:11:33: error:
• Number of parameters must match family declaration; expected 0
• In the equations for closed type family ‘T’
In the type family declaration for ‘T’
}}}
(As an aside, "expected only no parameters" is awkward, if there is some
legitimate way to generate this message. It should just be "expected no
parameters".)
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11623>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list