[Haskell-beginners] mapM etc.

Chaddaï Fouché chaddai.fouche at gmail.com
Sat Jul 2 09:55:50 CEST 2011


On Fri, Jul 1, 2011 at 10:48 PM, Alexey G <kreed131 at gmail.com> wrote:
> Try this:
>
>> mapM (\x -> getDeviceInfo x >>= print . name) [0..10]
>

Though they're not very well known, Control.Monad now contains
"composition" monad operators, so you can just write :

> mapM_ (getDeviceInfo >=> print . name) [0..10]

which is pretty elegant (to my eyes at least).

(>=>) :: (a -> m b) -> (b -> m c) -> a -> m c

-- 
Jedaï



More information about the Beginners mailing list