#2599: Improve error message for type rigidity
--------------------------------+-------------------------------------------
Reporter: simonpj | Owner: simonpj
Type: feature request | Status: new
Priority: normal | Milestone: 6.12 branch
Component: Compiler | Version: 6.8.3
Severity: normal | Keywords:
Difficulty: Unknown | Testcase:
Architecture: Unknown | Os: Unknown
--------------------------------+-------------------------------------------
When saying that a GADT match is given a non-rigid type, we should be more
explicit about where a type signature would help. For example, given the
program:
{{{
data E x = E x
data Foo a where
Foo :: Gadt a -> Foo a
data Gadt a where
GadtValue :: a -> Gadt (E a)
g = case undefined of
Foo GadtValue -> ()
}}}
I get the error message:
{{{
Test.hs:13:12:
GADT pattern match with non-rigid result type `t'
Solution: add a type signature
In a case alternative: Foo GadtValue -> ()
In the expression: case undefined of { Foo GadtValue -> () }
In the definition of `g':
g = case undefined of { Foo GadtValue -> () }
}}}
But where should the type signature be? A better hint would be:
{{{
Solution: add a type signature, probably at _TYPE_
(case undefined of { Foo GadtValue -> () }) :: _TYPE_
}}}
Similarly, we know when it's the scrutinee that needs a signature. And in
a do-binding the "scrutinee" is really the right-hand side. We can get
all this information from the matching context.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2599>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs