[Haskell-beginners] Code golf

Tilmann t_gass at gmx.de
Fri May 20 17:15:05 UTC 2016


Thank you for the references. I like the term 'bind2'. I had a look at 
Prelude.Generalized. Wow!

bind2  =  join  .::  liftM2; (.::) = (.) . (.) . (.)

Am 20.05.16 um 04:50 schrieb Silent Leaf:
> The interesting bit is, the following function > \φ ma mb -> join 
> (pure φ <*> ma <*> mb) which i like to write as follows using ((&) = 
> flip ($)) [infixl 1] > \φ ma mb -> pure φ <*> ma <*> mb & join (but 
> it's just personal taste) is very similar to (=<<), aka (flip (>>=)) 
> except the first argument (here φ) has type (a -> b -> m c) instead of 
> (a -> m b), and of course the lambda above takes an added argument too 
> (mb). Some could call it "bind2" (even if it's the flipped version of 
> (>>=) that is being generalized), and well, some do. For those 
> interested, there are several options are available to import it 
> (along possibly with some of its siblings), from several libraries. 
> (List possibly non exhaustive.) 
> http://hackage.haskell.org/package/prelude-generalize-0.4/docs/Prelude-Generalize.html#v:bind2 
> http://hackage.haskell.org/package/SimpleH-1.2/docs/Algebra-Monad.html#v:bind2 
> http://hackage.haskell.org/package/definitive-base-2.3/docs/Algebra-Monad-Base.html#v:bind2 
> your problem become btw then: > doIt = bind2 update a b
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160520/b15ede49/attachment.html>


More information about the Beginners mailing list