[Haskell-cafe] Re: Tutorial uploaded

John Meacham john at repetae.net
Thu Dec 22 12:58:51 EST 2005


On Thu, Dec 22, 2005 at 02:02:56PM +0000, Daniel Carrera wrote:
> I had never heard of mapM, or other -M functions. I can't imagine why 
> those would be needed. It seems like pointless duplication.

(!!!) then you are missing out. the M functions (and monadic traversal
functions in general) especially when combined with the mtl are some of
the best swiss army knives haskell has to offer. 

and it is map that is redundant.

map f xs = runIdentity $ mapM f xs
sequence = mapM id 

I have come to think of the monadic forms of these functions as the
'true' versions and the others as just common special cases.

though, not my most common function used from the prelude, it is up
there. and the most commonly used non-trivial function other than
return:

    922 mapM
    937 Nothing
   1017 not
   1061 error
   1433 String
   1456 Just
   1544 IO
   1777 map
   1810 show
   1972 text
   2595 Int
   5303 return

        John

-- 
John Meacham - ⑆repetae.net⑆john⑈ 


More information about the Haskell-Cafe mailing list