Using "type"
Simon Peyton-Jones
simonpj@microsoft.com
Thu, 9 May 2002 00:48:15 -0700
GHC currently takes the following (non-Haskell 98) attitude to type
synonyms:
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
Simon
| -----Original Message-----
| From: Samuel E. Moelius III [mailto:usmoeliu@mcs.drexel.edu]=20
| Sent: 04 May 2002 20:45
| To: haskell-cafe@haskell.org
| Subject: Using "type"
|=20
|=20
| I apologize if this question has been asked before...
|=20
| It seems to me the following code should be legal:
|=20
| type Thing m =3D m ()
| =09
| type Const a b =3D a
| =09
| f :: Thing m -> Thing m
| f x =3D x
| =09
| test :: Thing (Const Int) -> Thing (Const Int)
| test =3D f
|=20
| However, GHC gives the following error:
|=20
| 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
|=20
| But if you change the definition of Const
|=20
| newtype Const a b =3D MakeConst a
|=20
| the code compiles fine.
|=20
| Is this the desired behavior?
|=20
| 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?
|=20
| Sam Moelius
|=20
| _______________________________________________
| Haskell-Cafe mailing list
| Haskell-Cafe@haskell.org=20
| http://www.haskell.org/mailman/listinfo/haskell-cafe
|=20