[Haskell-cafe] usage of traversal

Michael Snoyman michael at snoyman.com
Tue Sep 23 07:23:06 UTC 2014


On Tue, Sep 23, 2014 at 10:12 AM, Kazu Yamamoto <kazu at iij.ad.jp> wrote:

> Hi Michael,
>
> Probably, you forgot to Cc: to haskell-cafe.
>
> > I'd be -1 on an operator, I think having a named function for this is a
> > good thing for readability of code.
> >
> > As far as good style: I personally think it is. In classy-prelude, I
> > actually export the Foldable-based `mapM` by default, and will regularly
> > use that (or forM) for this kind of code.
>
> With AMP, 'fmap' and 'liftM' are identical and we use <$> instead
> recently. Likewise, 'traverse' and 'mapM' are identical. If we
> introduce an operator, say <:>, we can forget 'traverse' and 'mapM'
> when writing code and can write:
>
>         getModificationTime <:> mfile
>
> This looks like function application like Applicative style.
>
> Just a thought.
>
> --Kazu
>

It's definitely true that with AMP the situation will be much improved, and
it makes more sense to use an operator here since it will cover what is
today two distinct functions. However, I think I'm overall still in favor
of sticking to the named function, since both `mapM` and `traverse` are
well known. This may just be a chicken-and-egg argument, however, and once
<:> takes hold it's just as readable as `mapM`.

Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140923/21966db6/attachment.html>


More information about the Haskell-Cafe mailing list