Partial application of type constructors?

John Meacham john at repetae.net
Tue Apr 19 05:34:22 EDT 2005


On Mon, Apr 18, 2005 at 09:20:46PM -0700, Conal Elliott wrote:
> GHC 6.4 objects to the following simple program, pointing to the partial
> application of the type constructor AddL.  Is there a work-around?
> 
>     {-# OPTIONS -fglasgow-exts #-}
>     data LMap a b
>     type AddL arr a b = a `arr` LMap a b
>     data DFunA arr a b = DFunA (a `arr` b) (DFunA (AddL arr) a b)
> 
> The complete error message:
> 
>     Type synonym `AddL' should have 3 arguments, but has been given 1
>     When checking the data constructor:
>       forall arr a b. DFunA (arr a b) (DFunA (AddL arr) a b)
>     In the data type declaration for `DFunA'
> 
> Is there a serious difficulty with handling partial type applications?

Yes, it is difficult for a number of reasons which I am sure others know
better but the gist is it would make the type system undecidable. Right
now you will have to use data or newtypes if you want to partially apply
them, or eta-reduce your type synonym if possible.

This seems to be such a common question, perhaps someone could write up
something on the wiki that goes into more depth on what the issues are
with generalized type synonyms?

        John

-- 
John Meacham - ⑆repetae.net⑆john⑈ 


More information about the Glasgow-haskell-users mailing list