[Haskell-cafe] classes with types which are wrapped in

Steffen Schuldenzucker sschuldenzucker at uni-bonn.de
Fri Jan 22 12:42:04 EST 2010

Hi Andrew,

Andrew U. Frank wrote:
> here a simplistic case (i know that A could be reduced to [], my real cases 
> are more complicated).
> data A b = A b [b]
> data Asup x ab y = Asup x ab y
> class X a b where
>     push :: b -> a b -> a b
> instance X A Int where
>     push b' (A b bs) = A b' (b:bs)
> instance X Asup Char Int Float where
>     push b' (Asup a b c) = Asup a (push b' b) c
If I understand you correctly, what you want here are type level 
lambdas. Abusing notation:

instance X (\t -> Asup Char t Float) Int where
    push b' (Asup a b c) = Asup a (push b' b) c

However, type level lambdas introduce lots of ambiguities and are 
therefore AFAIK not supported in haskell[1].

> if i try with a type
> type A_2 b = Asup Char (A b) Float
> instance X A_2 Int where
>     push b' (Asup a b c) = Asup a (push b' b) c
> (and --TypeSynonymInstances) i get:
> Type synonym `A_2' should have 1 argument, but has been given 0
>     In the instance declaration for `X A_2 Int'
However, this error message looks strange. I tried to reduce this to a 
simpler case[1] and got the same message.
Does anyone know why it complains just about the number of type 
arguments (which is correct) ?

-- Steffen

[1] http://www.mail-archive.com/haskell-cafe@haskell.org/msg69579.html
[2] http://ideone.com/9BAj7MG7
(note that ideone is using ghc-6.8)

More information about the Haskell-Cafe mailing list