[GHC] #1158: Problem with GADTs and explicit type signatures
GHC
trac at galois.com
Tue Feb 20 07:32:48 EST 2007
#1158: Problem with GADTs and explicit type signatures
-------------------------+--------------------------------------------------
Reporter: guest | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.6
Severity: normal | Keywords:
Difficulty: Unknown | Testcase:
Architecture: Unknown | Os: Unknown
-------------------------+--------------------------------------------------
{{{
{-# OPTIONS_GHC -fglasgow-exts #-}
module Main where
data Exp a where
Val :: a -> Exp b
App :: Exp a -> Exp b
instance Show (Exp a) where
show (Val _) = "Val"
show (App _) = "App"
class LiftToExp a b where
liftToExp :: a -> Exp b
instance LiftToExp (Exp a) a where
liftToExp = id
instance Floating a => LiftToExp a b where
liftToExp v = Val v :: Exp b
{-
Uncommenting the type signature below causes GHCi to fail to load the
file:
test.hs:45:14:
Overlapping instances for LiftToExp a a11
arising from use of `liftToExp' at test.hs:45:14-24
Matching instances:
instance (Floating a) => LiftToExp a b -- Defined at test.hs:19:0
instance LiftToExp (Exp a) a -- Defined at test.hs:16:0
(The choice depends on the instantiation of `a, a11'
Use -fallow-incoherent-instances to use the first choice above)
In the first argument of `App', namely `(liftToExp x)'
In the expression: App (liftToExp x)
In the definition of `test': test x = App (liftToExp x)
However typing :t test at the GHCi prompt gives this exact signature.
Tested with GHC 6.6 (compiler and interpreter) under OS X 10.4.8 on an
iMac G5.
-}
--test :: (LiftToExp a a1) => a -> Exp b
test x = App (liftToExp x)
main = putStrLn $ show (test (3.0::Float)::Exp Int)
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1158>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list