Open habbler opened 6 years ago
The problem with this is that we would need to manually write one instance for each tuple size since there's no abstraction over all tuple sizes. Maybe we can get away with CPP macros?
I would suggest generating the tuple instances. What I don't know is whether this could be used to help improve the compile times.
I suspect the compile time performance is due to https://ghc.haskell.org/trac/ghc/ticket/8095 I guess a fix from GHC will be necessary.
This is done in jrec: https://github.com/juspay/jrec/blob/master/src/JRec/Tuple.hs
The tuple is generated with a script in the bin/
folder. The same script can be adapted for superrecord.
TH is also an option.
I think it brings record creation times from O(n^2) to O(n), but I have not benchmarked it.
I see that newest version of vinyl supports creating records from tuples. Maybe supporting this in superrecord would help with the problem of slow compile times? (I tried superrecord out, found it quite good, but decided not to live with the longer compile times). i.e. for a 7-tuple we would know in advance we are creating a record with 7 fields.
Going in the other direction would be nice as will. A function that maps from a tuple of field labels to a tuple of values. Would make reading multiple fields more concise.