Think of "traverse" as a "mapA", as it's just like Data.Traversable.mapM, but with the Applicative class constraint instead of the Monad one. <br>I've always wondered why it isn't called this way, sequenceM equivalent for Applicatives is sequenceA for instance.<br>
<br><div class="gmail_quote">Le 28 mars 2012 22:19, Christopher Done <span dir="ltr"><<a href="mailto:chrisdone@googlemail.com">chrisdone@googlemail.com</a>></span> a écrit :<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 28 March 2012 22:05, Matthew Steele <<a href="mailto:mdsteele@alum.mit.edu">mdsteele@alum.mit.edu</a>> wrote:<br>
> Doesn't for already exist, in Data.Traversable? Except that for =<br>
> flip traverse.<br>
<br>
</div>Traverse doesn't fit the type of fmap, it demands an extra type constructor:<br>
<br>
traverse :: (Traversable t,Applicative f) => (a -> f b) -> t a -> f (t b)<br>
<br>
fmap :: Functor f => (a -> b) -> f a -> f b<br>
<br>
Note the (a -> f b) instead of (a -> b).<br>
<br>
E.g.<br>
<br>
fmap :: (a -> b) -> [a] -> [b]<br>
<br>
can't be expressed with traverse, you can only get this far:<br>
<br>
traverse :: (a -> [b]) -> [a] -> [[b]]<br>
<br>
Unless I'm missing something.<br>
<div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br>