[Haskell-cafe] Proposal: Applicative => Monad: Call for consensus
hesselink at gmail.com
Tue Jan 25 08:44:57 CET 2011
On Tue, Jan 25, 2011 at 05:13, Ryan Ingram <ryani.spam at gmail.com> wrote:
> On Fri, Jan 21, 2011 at 7:58 PM, Casey Hawthorne <caseyh at istar.ca> wrote:
>> uj supplied this:
>> About the discussion
>> "putStrLn (readLn + (5 :: Int))"..
>> I'll write it as the following line,
>> importing Control.Applicative
>> main = (+) readLn (return 3)
>> They look almost exactly same in my eyes..
> You're missing some bits.
> main = print =<< liftM2 (+) readLn (return 3)
> Which I assert looks like more line noise than some perl programs I've read. :)
Why not just:
main = print . (+3) =<< readLn
This reads almost as well as a function composition f . g . h, I think.
P.S. I wanted to say you could also write it left-to-right using >>>
from Control.Arrow, but that need parentheses:
main = readLn >>= ((+3) >>> print)
More information about the Haskell-Cafe