[Haskell-beginners] mapM etc.
Chaddaï Fouché
chaddai.fouche at gmail.com
Sat Jul 2 10:00:00 CEST 2011
On Sat, Jul 2, 2011 at 9:55 AM, Chaddaï Fouché <chaddai.fouche at gmail.com> wrote:
> 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]
>>
>
>> mapM_ (getDeviceInfo >=> print . name) [0..10]
>
Or maybe, to be more consistent order-wise :
> mapM_ (print . name <=< getDeviceInfo) [0..10]
>
> (>=>) :: (a -> m b) -> (b -> m c) -> a -> m c
>
Oops, forgot the constraint :
(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> (a -> m c)
--
Jedaï
More information about the Beginners
mailing list