| The first version doesn't compile - the error is: | Type synonym `F3' should have 1 argument, but has been given 0 | In the type: Pair F3 F2 | While checking the type signature for `p'
Type synonyms in Haskell must be saturated (i.e. given all their argments). GHC lifts this restriction slightly; see http://haskell.cs.yale.edu/ghc/docs/latest/html/users_guide/type-extensi ons.html#TYPE-SYNONYMS in the user manual. (Which I hope you have read.) | The other version uses newtype instead of type synonyms for F2 and F3. | This one compiles without problems. That's right. Newtypes don't need to be saturated. Reason: with newtypes the type (F3 a) and the representation type (a->a->a) are distinct, with explicit coercions between them. This makes type inference work right. We can't do this for type synonyms because that'd need higher order unification, and loss of principal types. Simon | | {-# OPTIONS -fglasgow-exts #-} | | module T2 where | | newtype F3 a = F3 (a -> a -> a) | newtype F2 a = F2 (a -> a) | | data Pair c1 c2 = Pair (forall a. c1 a) (forall b. c2 b) | | swap :: Pair c1 c2 -> Pair c2 c1 | swap (Pair f g) = Pair g f | | f2 :: F2 a | f2 = F2 id | | f3 :: F3 a | f3 = F3 const | | p :: Pair F3 F2 | p = Pair f3 f2 | | There is probably some restriction I don't know about or haven't | recognized in this particular case. I hope you will enlighten me. | | > Simon | | Best regards, | Tom | | -- | .signature: Too many levels of symbolic links _______________________________________________ Glasgow-haskell-bugs mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
