<div dir="ltr">Hi Jonathon,<div><br></div><div>Traversable instances do not change the shape of a data structure!</div><div><br></div><div>On the contrary, the whole purpose of traverse is to combine effectful computations, stored in a structure without changing its shape! While Foldable folds over the contents of a data structure (via Monoid), Traversable allows you to fold over the effects attached to the contents of that structure (via Applicative).</div><div><br></div><div>It turns out that by using Const applicative functor you can use traverse to perform foldMap! Thus every Traversable is trivially a Foldable (see foldMapDefault).</div><div>Similarly, every Traversable is trivially a Functor if you use Identity applicative functor (see fmapDefault).</div><div>This is why Traversable has those Functor and Foldable constraints, not because it relies on fmap or foldMap.<br></div><div><br></div><div>Kind regards,</div><div>Nick</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, 4 May 2017 at 10:49 Jonathon Delgado <<a href="mailto:voldermort@hotmail.com">voldermort@hotmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It seems that Traversable is doing two things:<br>
<br>
1) Changing the shape of a data structure.<br>
2) Folding over the contents of a data structure.<br>
<br>
Traversable requires Foldable to enable 2, but Traversable is also applied to types such as (,) where only 1 is relevant.<br>
<br>
If this is correct, follow-up questions would be:<br>
<br>
1) For educational purposes, could these concerns be split without substantial drawback?<br>
2) For practical purposes, could this be done without breaking a lot of existing code?<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>