Re: [Haskell-cafe] usage of traversal

On Tue, Sep 23, 2014 at 10:12 AM, Kazu Yamamoto
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

With AMP, 'fmap' and 'liftM' are identical and we use <$> instead recently. Likewise, 'traverse' and 'mapM' are identical.
Both Kazu and Michael are perfectly aware of the following but it's important to set the record straight: The function liftM is a specialization of fmap. Both functions operate the same (which is what is meant by 'identical') on mutually admissible values, but liftM restricts the domain of admissibility only to functors that are also monadic. Similarly, mapM is a specialization of traverse. Here, two functors are involved where one is weakened and the other strengthened. If we introduce an operator, say <:>, we can forget 'traverse' and 'mapM' Have you considered the traditional way of using your own operators, i.e. by spinning one's own Missing Haskell library, like John Goerzen did? The direction you're suggesting requires familiarity with the libraries-haskell process. -- Kim-Ee

On Tue, Sep 23, 2014 at 5:34 PM, Kim-Ee Yeoh
Similarly, mapM is a specialization of traverse. Here, two functors are involved where one is weakened and the other strengthened.
Wait, that's not right. Both functors are weakened going from mapM to traverse. They are sharpened going the other way round. -- Kim-Ee
participants (2)
-
Kim-Ee Yeoh
-
Michael Snoyman