Visitar URL original
Fix isNormalized for field selections by sjakobi · Pull Request #1210 · dhall-lang/dhall-haskell · GitHub
Skip to content

Fix isNormalized for field selections - #1210

Merged
sjakobi merged 1 commit into
masterfrom
sjakobi/1209-isNormalized
Aug 7, 2019
Merged

sjakobi merged 1 commit into
masterfrom
sjakobi/1209-isNormalized

Conversation

@sjakobi

@sjakobi sjakobi commented Aug 6, 2019

Copy link
Copy Markdown
Collaborator

In expressions like

({ x : Optional/fold } // {=}).x

isNormalized didn't check if the expression being selected from
was normalized.

Fixes #1209.

In expressions like

    ({ x : Optional/fold } // {=}).x

isNormalized didn't check if the expression being selected from
was normalized.

Fixes #1209.
@sjakobi
sjakobi force-pushed the sjakobi/1209-isNormalized branch from 3517a95 to 4fe4a0b Compare August 6, 2019 23:23
Comment thread dhall/src/Dhall/Core.hs
Combine x@(RecordLit m) y -> loop x && loop y && Dhall.Map.member k m
Combine x (RecordLit m) -> loop x && Dhall.Map.toList (fmap loop m) == [(k, True)]
Prefer x@(RecordLit m) y -> loop x && loop y && Dhall.Map.member k m
Combine (RecordLit m) _ -> Dhall.Map.member k m && loop r

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps move the loop r check above so that does not have to be repeated across the branches, like this:

Field r k -> loop r && case r of
    RecordLit _ -> False
    …

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually did that in a previous version of this fix, but I just couldn't handle the inefficiency! ;)

If you don't mind too much I'd slightly prefer to keep the fix as it is now.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind! It was just a suggestion 🙂

@sjakobi
sjakobi merged commit 4559a27 into master Aug 7, 2019
@sjakobi
sjakobi deleted the sjakobi/1209-isNormalized branch August 7, 2019 01:44
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

Successfully merging this pull request may close these issues.

Test failure in "isNormalized should be consistent with normalize"

2 participants