#3638: Redundant signature required with RULES and GADTs
-----------------------------+----------------------------------------------
Reporter: rl | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler (Type checker)
Version: 6.13 | Severity: normal
Keywords: | Testcase:
Os: Unknown/Multiple | Architecture: Unknown/Multiple
-----------------------------+----------------------------------------------
Here is a small program:
{{{
data T a where TInt :: T Int
foo :: T Int -> Int
foo TInt = 0
{-# RULES "foo" forall x. foo x = case x of { TInt -> 0 } #-}
}}}
GHC complains:
{{{
GADT pattern match with non-rigid result type `t'
Solution: add a type signature for the entire case expression
In a case alternative: TInt -> 0
In the expression: case x of { TInt -> 0 }
When checking the transformation rule "foo"
}}}
And indeed, changing the rule to
{{{
{-# RULES "foo" forall x. foo x = case x of { TInt -> 0 } :: Int #-}
}}}
works. The signature is redundant, though, because the type of the case is
determined by the type of the rule head.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3638>
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