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

Check normalizeWithM for consistency with normalize #1126

Merged
merged 3 commits into from
Jul 19, 2019

Conversation

sjakobi
Copy link
Collaborator

@sjakobi sjakobi commented Jul 18, 2019

  • 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.

* 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.
@sjakobi
Copy link
Collaborator Author

sjakobi commented Jul 18, 2019

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)
Copy link
Collaborator Author

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…

Copy link
Collaborator

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)
Copy link
Collaborator

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

@mergify mergify bot merged commit b4f71b2 into master Jul 19, 2019
@mergify mergify bot deleted the sjakobi/1114-test-normalizeWithM branch July 19, 2019 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Low test coverage of normalizeWithM
2 participants