Re: [Haskell-cafe] Type synonym application
On Sun, Mar 18, 2007 at 05:47:21PM +, 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 like: (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. Thanks Ian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Type synonym application
On Mon, 19 Mar 2007, Ian Lynagh wrote: On Sun, Mar 18, 2007 at 05:47:21PM +, 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. In Haskell 98 it is not allowed to define type synonymes in a partially applied manner. That is, there is no alternative to type WithList a b c = b [a] c ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Type synonym application
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) -- error: `FooPair' is not applied to enough type arguments ints2 :: (WithList Int FooPair) [Int] ints2 = ([1], id) -- after manually applying the first type synonym ints3 :: FooPair [Int] [Int] ints3 = ([1], id) _ Live Search Maps find all the local information you need, right when you need it. http://maps.live.com/?icid=hmtag2FORM=MGAC01 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Type synonym application
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, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe