Hi Miguel,
That's a nice way of writing it.
Thanks,
-John
What do you need that for?
Can you live with
infixl |$|
(|$|) :: [a -> r] -> a -> [r]
fs |$| x = map ($ x) fs
and, instead of "broadcast fs a b" use
fs |$| a |$| b
?
On 13 Feb 2009, at 02:34, John Ky wrote:
_______________________________________________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
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe