-
Notifications
You must be signed in to change notification settings - Fork 211
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
Check normalizeWithM for consistency with normalize #1126
Conversation
* Implements constant folding of Natural/fold applications normalizeWithM. * Changes the Arbitrary Var instance to generate only non-negative indices. Otherwise failures like this one would pop up: normalizeWithM should be consistent with normalize: FAIL (8.51s) *** Failed! Falsified (after 318133 tests and 6 shrinks): Let (Binding {variable = "", annotation = Nothing, value = List} :| []) (Var (V "" (-1))) Var (V "" (-1)) /= Var (V "" (-2)) Use --quickcheck-replay=180244 to reproduce. Fixes #1114.
Sadly I couldn't quite figure out the root cause of the discrepancy in the let-shifting. |
normalizeWithMIsConsistentWithNormalize expression = | ||
case Control.Spoon.spoon (Dhall.Core.normalize expression :: Expr () Import) of | ||
Just nf -> | ||
let nfM = runIdentity (Dhall.Core.normalizeWithM (\_ -> Identity Nothing) expression) |
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.
Would it be a good idea to export this "trivial" normalizer as an example?
Something like
boringNormalizer :: Normalizer a
boringNormalizer _ = Identity Nothing
Not sure about the name…
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.
Probably not. I doubt anybody would use it
Previously it could produce about any number, not just non-negative ones.
normalizeWithMIsConsistentWithNormalize expression = | ||
case Control.Spoon.spoon (Dhall.Core.normalize expression :: Expr () Import) of | ||
Just nf -> | ||
let nfM = runIdentity (Dhall.Core.normalizeWithM (\_ -> Identity Nothing) expression) |
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.
Probably not. I doubt anybody would use it
Implements constant folding of Natural/fold applications normalizeWithM.
Changes the Arbitrary Var instance to generate only non-negative indices.
Otherwise failures like this one would pop up:
Fixes #1114.