Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create records from tuples #20

Open
habbler opened this issue Jul 31, 2018 · 4 comments
Open

Create records from tuples #20

habbler opened this issue Jul 31, 2018 · 4 comments

Comments

@habbler
Copy link

habbler commented Jul 31, 2018

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.

@agrafix
Copy link
Owner

agrafix commented Aug 1, 2018

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?

@habbler
Copy link
Author

habbler commented Aug 2, 2018

I would suggest generating the tuple instances.
What I don't know is whether this could be used to help improve the compile times.

@habbler
Copy link
Author

habbler commented Aug 7, 2018

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.

@neongreen
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants