Proposal: Add conspicuously missing Functor instances for tuples

Ryan Scott ryan.gl.scott at gmail.com
Mon Jan 18 21:46:34 UTC 2016


Edward Kmett outlines his reasons why he finds instances for (,)
useful here: https://www.reddit.com/r/haskell/comments/3pfg7x/either_and_in_haskell_are_not_arbitrary/cw65ck2

Speaking for myself, I find the Traversable instance for (,)
incredibly useful. It's quite nice to build up a list of results
alongside a state (i.e, (state, [result]) ), and then traverse over
each of the results such that the new results each have their own copy
of the state (i.e., [(state, result)] ). That kind of patterns arises
quite often in lensy code, and the Traversable instance for (,) is
perfect for the job.

Right now, if you want to have two different states, you have to
employ a kludge (something like ((state1, state2), [result]) ) to get
around the fact that there's no Traversable instance for (,,), (,,,),
etc.

Ryan S.


More information about the Libraries mailing list