[EMAIL PROTECTED] wrote:
> Some time ago there was a discussion about what to call reverse
> composition (I can't find it in the archive - needs a search option?)
>
> Just now I thought of .~ from . for composition and ~ (tilde, but
> commonly called twiddle) for twiddling the order about.
>
> Maybe we could adopt that as normal usage?
I've also seen .| and |. used for this purpose (by
analogy with Unix pipes.)
John Hughes' Arrow library spells it ">>>", but generalized
to arbitrary arrows. At the (->) instance it's the same
as "flip (.)".
Along the same lines, are there accepted conventional infix operators
for the functions with types:
(a0 -> b0) -> (a1 -> b1) -> (a0,a1) -> (b0,b1)
(a -> b0) -> (a -> b1) -> a -> (b0,b1))
(a0 -> b0) -> (a1 -> b1) -> Either a0 a1 -> Either b0 b1
(a0 -> b) -> (a1 -> b) -> Either a0 a1 -> b
(the last one is called "either" in the standard Prelude).
I personally like:
(f <*> g) (x,y) = (f x, g y)
(f <&> g) x = (f x, g x)
(f <+> g) (Left x) = Left (f x)
(f <+> g) (Right y) = Right (g y)
(f <|> g) (Left x) = f x
(f <|> g) (Right y) = g y
Hughes spells these ***, &&&, +++, and ||| (again generalized
to arbitrary arrows), but those don't look as nice typeset IMHO.
I also like:
apfst :: (a -> c) -> (a,b) -> (c,b)
apsnd :: (b -> c) -> (a,b) -> (a,c)
apl :: (a -> c) -> Either a b -> Either c b
apr :: (b -> c) -> Either a b -> Either a c
These are called "first", "second", "left", and "right"
in the Arrow library.
--Joe English
[EMAIL PROTECTED]