Matt Harden writes:

> That doesn't work either: Haskell98 doesn't allow type synonyms to be
> used to define instances.  GHC supposedly lifts this restriction, but it
> complains:  (I'm using version 4.02)
> 
> >     type synonym `Func2' should have 3 arguments, but has been given 2
> >     When checking kinds in `Func2 a b'
> >     When checking kinds in `Functor (Func2 a b)'
> 
> So I guess GHC only accepts type synonyms as instances when the kind of
> the class is *.

The actual restriction is that type synonyms must always be fully applied; they can be 
at any kind.  Thus in your first example,

type Func a = (->) a
instance Functor (Func a) where
  ... 

works fine (in GHC).

This doesn't solve your problem, however.  I believe (someone will correct me if I'm 
wrong) that you're stuck here.  What you really need is a type lambda:

type Func2 a b = /\c. a->(b->c)

but this isn't provided in Haskell.

--KW 8-)
-- 
: Keith Wansbrough, MSc, BSc(Hons) (Auckland) -------------------:
: PhD Student, Computer Laboratory, University of Cambridge, UK. :
: Native of Antipodean Auckland, New Zealand: 174d47'E, 36d55'S. :
: http://www.cl.cam.ac.uk/users/kw217/ mailto:[EMAIL PROTECTED] :
:----------------------------------------------------------------:



Reply via email to