
26 Dec
2014
26 Dec
'14
10:39 p.m.
On 26/12/14 20:18, Michael Orlitzky wrote:
I have tons of code like this:
from_tuple = uncurry MLBBoxScoreGameBreakdownXml to_tuple (MLBBoxScoreGameBreakdownXml a h) = (a,h)
The first function, from_tuple, generalizes easily with `uncurryN` from Data.Tuple.Curry. But I'm wondering, is there any generic function that will take a simple data type and cram it into a tuple?
So instead of writing,
from_tuple = uncurryN MLBBoxScoreGameBreakdownTeamXml to_tuple (MLBBoxScoreGameBreakdownTeamXml w x y z) = (w,x,y,z)
I could just do,
from_tuple = uncurryN MLBBoxScoreGameBreakdownTeamXml to_tuple = toTupleGeneric
because things get real ugly when there are ~20 fields in the data type.
Should be easy to do with the generics-sop package. Roman