[Haskell-cafe] Type families not as useful over functions
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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe