[Haskell-cafe] Proposal: Applicative => Monad: Call for consensus

Ryan Ingram ryani.spam at gmail.com
Tue Jan 25 05:13:18 CET 2011


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. :)

Now, you *can* get away with simplifying this to
main = print =<< (readLn :: IO Int) + 3
assuming instance Num a => Num (IO a), which sort-of works (show
instance and pattern matching are both quite broken; given the naive
implementation of fib, fib readLn will give you quite a surprising
result!)

But I think this case proves the point quite well: it's a special case
where Num turns out to be very friendly.  Why can't the whole language
be that friendly?

  -- ryan



More information about the Haskell-Cafe mailing list