[email protected]
[Top] [All Lists]

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

Subject: Re: [Haskell-cafe] classes with types which are wrapped in
From: Steffen Schuldenzucker
Date: Fri, 22 Jan 2010 18:42:04 +0100
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/[email protected]/msg69579.html
[2] http://ideone.com/9BAj7MG7
(note that ideone is using ghc-6.8)

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

<Prev in Thread] Current Thread [Next in Thread>