[Haskell-cafe] Type synonym application

Bulat Ziganshin bulat.ziganshin at gmail.com
Sun Mar 18 13:55:45 EDT 2007


Hello C,

Sunday, March 18, 2007, 8:47:21 PM, you 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)

ghc fixes kinds of parameters in 'type' definitions. in your
definition, it fixes arity of a and b at minimal level where
definition can be typechecked. if that isn't what you need, you should
add manual kind definitions:

type WithList a (b :: * -> * -> * ) = b [a]
type FooPair a b = (b, a -> b)

(it will work in ghc, probably hugs and haskell-prime, but not in
haskell-98. you will need -fglasgow-exts ghc option to compile this
module. read more about kinds in GHC manual)

another option is to add one more parameter to WithList giving ghc
a hint about kind of b parameter :)

type WithList a b c = b [a] c
type FooPair a b = (b, a -> b)


-- 
Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com



More information about the Haskell-Cafe mailing list