Thu, 9 May 2002 00:48:15 -0700
GHC currently takes the following (non-Haskell 98) attitude to type
first expand type synonyms
only then check for partial applications of type synonyms
then perform type checking
So in his case type for f expands to:
f :: m () -> m ()
test :: Int -> Int
You can see how the type for test comes out:
Thing (Const Int) =3D Const Int () =3D Int
Now GHC tries to unify=20
m () with Int
and fails, as it should. The error message is phrased in terms
of the original un-expanded types, which is usually a good thing but
on this occasion gives a rather odd looking error message.
GHC shouldn't really do this lazy checking unless you say -fglasgow-exts
| -----Original Message-----
| From: Samuel E. Moelius III [mailto:firstname.lastname@example.org]=20
| Sent: 04 May 2002 20:45
| To: email@example.com
| Subject: Using "type"
| I apologize if this question has been asked before...
| It seems to me the following code should be legal:
| type Thing m =3D m ()
| type Const a b =3D a
| f :: Thing m -> Thing m
| f x =3D x
| test :: Thing (Const Int) -> Thing (Const Int)
| test =3D f
| However, GHC gives the following error:
| Couldn't match `Thing m' against `Thing (Const Int)'
| Expected type: Thing m
| Inferred type: Thing (Const Int)
| Expected type: Thing (Const Int) -> Thing (Const Int)
| Inferred type: Thing m -> Thing m
| But if you change the definition of Const
| newtype Const a b =3D MakeConst a
| the code compiles fine.
| Is this the desired behavior?
| Is it the case that when you have quantification of a type=20
| variable of=20
| kind * -> * (in this case, m), that variable may only become=20
| bound to a=20
| type constructor?
| Sam Moelius
| Haskell-Cafe mailing list