[Haskell-cafe] Type synonym application

Ian Lynagh igloo at earth.li
Mon Mar 19 12:39:21 EDT 2007

On Sun, Mar 18, 2007 at 05:47:21PM +0000, C Rodrigues wrote:
> Type synonyms aren't applied as I would expect during kind checking.  
> What's going on here?
> type WithList a b = b [a]
> type FooPair a b = (b, a -> b)
> -- error: `WithList' is applied to too many type arguments
> ints1 :: WithList Int FooPair [Int]
> ints1 = ([1], id)

That's caused by kind defaulting, as bulat said.

> -- error: `FooPair' is not applied to enough type arguments
> ints2 :: (WithList Int FooPair) [Int]
> ints2 = ([1], id)

Type synonyms must be fully applied, i.e. you must always have something
    (FooPair a Int)
in types, not just FooPair, (FooPair a) or (FooPair Char).

The reason is that otherwise you get type-level lambdas, and type
inference becomes undecidable.


More information about the Haskell-Cafe mailing list