-
Notifications
You must be signed in to change notification settings - Fork 13
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
Batch constraints to within maxTupleSize in deriveArgDict #48
base: develop
Are you sure you want to change the base?
Batch constraints to within maxTupleSize in deriveArgDict #48
Conversation
Can you add a test with a large sum type? |
src/Data/Constraint/Extras/TH.hs
Outdated
batchConstraints :: [Type] -> Type | ||
batchConstraints cs | ||
| length cs == 0 = TupleT 0 | ||
| otherwise = AppT (AppT (TupleT 2) initialBatch) (batchConstraints rest) | ||
where | ||
(initial, rest) = splitAt (maxTupleSize - 1) cs | ||
initialBatch = foldl AppT (TupleT (length initial)) initial | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be better to do something like
batchConstraints :: [Type] -> Type | |
batchConstraints cs | |
| length cs == 0 = TupleT 0 | |
| otherwise = AppT (AppT (TupleT 2) initialBatch) (batchConstraints rest) | |
where | |
(initial, rest) = splitAt (maxTupleSize - 1) cs | |
initialBatch = foldl AppT (TupleT (length initial)) initial | |
batchConstraints :: [Type] -> Type | |
batchConstraints cs | |
| length cs <= maxTupleSize = foldl AppT (TupleT (length cs)) cs | |
| otherwise = batchConstraints $ batchConstraints <$> chunkBy maxTupleSize cs |
maybe there is an issue, but that seems about right. I am out of time to think about this ATM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seemed to work and I'm very happy to make the change. I couldn't find a chunkBy
, or any function :: Int -> [a] -> [[a]]
, in base
or an existing dependency, so I just wrote an implementation in this library rather than add a new library dependency.
a21dc28
to
c9fdfd9
Compare
This appears to have been fixed by #35. |
c9fdfd9
to
895cc79
Compare
Looks like the test doesn't pass |
This PR fixes #47 by batching constraints to never exceed
maxTupleSize
.