[Haskell-cafe] Type families not as useful over functions
John Ky
newhoggy at gmail.com
Thu Feb 12 18:34:42 EST 2009
Hi Haskell Cafe,
I tried using type families over functions, but when I try it complains that
the two lines marked conflict with each other.
class Broadcast a where
type Return a
broadcast :: a -> Return a
instance Broadcast [a -> r] where
type Return [a -> r] = a -> [r] -- Conflict!
broadcast fs a = []
instance Broadcast [a -> b -> r] where
type Return [a -> b -> r] = a -> b -> [r] -- Conflict!
broadcast fs a b = []
Given that in Haskell, every function of n+1 arguments is also a function of
n arguments, this is likely the cause of the conflict.
In this case, currying is not my friend.
Unfortunately this means I'm stuck with numbered function names:
bc0 :: [r] -> [r]
bc0 rs = rs
bc1 :: [a -> r] -> a -> [r]
bc1 [] a = []
bc1 (r:rs) a = (r a):bc1 rs a
bc2 rs a b = rs `bc1` a `bc1` b
bc3 rs a b c = rs `bc1` a `bc1` b `bc1` c
-- etc
Cheers,
-John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090213/fa43a6c1/attachment-0001.htm
More information about the Haskell-Cafe
mailing list