Add flipped fmap
Isaac Dupree
ml at isaac.cedarswampstudios.org
Wed Apr 7 13:31:23 EDT 2010
On 04/07/10 09:58, Felipe Lessa wrote:
> <$$> will be as concise and useful as<$>, maybe even more,
> because `flip fmap` isn't valid.
This is the annoying part. Aw, Haskell! I suppose we could name the
combinator `flipfmap`... and it would be clear what it meant...
I disagree with the consistency argument. I don't think <*> -> <**> is
a very good precedent. It has confused me. Far more people are
familiar with functor than applicative (so this precedent would be
applied mostly to an audience who's unfamiliar with it). >>= -> =<< ,
although perhaps silly, at least looks enough like a mirrored version
that you can guess...
I'd say "let's fix the fixity of fmap!" except we can't because Prelude
exports it.
Besides, IMHO fixity isn't too big a deal, because one can use
parentheses and they're rather less confusing to read than things being
in the "wrong" order or expressions using symbol-operators that the
reader doesn't know. I've used `fmap`, infix like that, sometimes...
although more recently I've come to think that it's not necessary to use
infix operators at all for clarity. A thought: for
> do m1
> m2
> m3 <$$> bigPieceOfCodeThatVisuallyBreaks
> theSequentialNatureOfADoExpression
how about using
do m1
m2
flip fmap m3 $ bigPieceOfCodeThatVisuallyBreaks
theSequentialNatureOfADoExpression
?
(not sure though.. I like using "forM_" more than "flip mapM_"..)
-Isaac
More information about the Libraries
mailing list