Why Does This Typecheck?
Main> :t baz baz :: Foo a => Char' a -> a Main> :t v v :: Char' BW Main> :t test1 test1 :: Bool Main> :t (baz v) baz v :: Foo a => a Why doesn't the typechecker unify Char' BW with a and therefore the type of test1 = baz v becomes Char' BW resulting in a type error by not being able to unify Char' BW with Char' Bool? Dominic. class Foo a where foo :: Char -> a instance Foo Bool where foo 'F' = False foo 'T' = True data BW = Black | White deriving Show instance Foo BW where foo 'B' = Black foo 'W' = White type Char' a = Char baz :: Foo a => Char' a -> a baz x = foo x v :: Char' BW v = 'B' test1 :: Bool test1 = baz v
Please ignore my last message. I assume the answer is that Char' a is replaced everywhere by Char before the typechecker gets a look in. Dominic.
participants (1)
-
Dominic Steinitz