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

Implement Optional/build with fusion #44

Merged
merged 1 commit into from May 1, 2017

Conversation

Projects
None yet
2 participants
@markus1189
Collaborator

markus1189 commented May 1, 2017

Finally got around to do this ;)

  • Defines a new primitive OptionalFold
  • Implements normalization:
    • inlining of Optional/build if constants are used as args
    • fusion of fold/build and build/fold
@Gabriel439

This looks great! My main suggestion is to add two more test cases. See below

Show outdated Hide outdated src/Dhall/Core.hs Outdated
check0 _ = False
check1 just nothing (App (Var (V just' n)) _) =
just == just' && n == (if just == nothing then 1 else 0)

This comment has been minimized.

@Gabriel439

Gabriel439 May 1, 2017

Collaborator

Related to your previous question: this is very similar to how the more efficient version of normalization would work. It's just that I wrote isNormalized long after I wrote normalize so I wrote isNormalized with more careful attention to performance

@Gabriel439

Gabriel439 May 1, 2017

Collaborator

Related to your previous question: this is very similar to how the more efficient version of normalization would work. It's just that I wrote isNormalized long after I wrote normalize so I wrote isNormalized with more careful attention to performance

Show outdated Hide outdated src/Dhall/TypeCheck.hs Outdated
where test label inp out = testCase label $ do
isNormalized (e inp) @?= False
normalize' (e inp) @?= out
e inp = (OptionalFold `App` Text `App` OptionalLit Text inp `App`

This comment has been minimized.

@Gabriel439

Gabriel439 May 1, 2017

Collaborator

Clever use of infix App! That would make the normalization code a lot easier to read with fewer parentheses since you I believe can also pattern match on an infix constructor

@Gabriel439

Gabriel439 May 1, 2017

Collaborator

Clever use of infix App! That would make the normalization code a lot easier to read with fewer parentheses since you I believe can also pattern match on an infix constructor

Show outdated Hide outdated tests/Normalization.hs Outdated
Implement Optional/build with fusion
- Defines a new primitive `OptionalFold`
- Implements normalization:
  - inlining of Optional/build if constants are used as args
  - fusion of fold/build and build/fold
@markus1189

This comment has been minimized.

Show comment
Hide comment
@markus1189

markus1189 May 1, 2017

Collaborator

Thanks for the review. I addressed all of your points (tests all pass, yay!)

(And yes you can use infix notation for pattern matching ;) )

Collaborator

markus1189 commented May 1, 2017

Thanks for the review. I addressed all of your points (tests all pass, yay!)

(And yes you can use infix notation for pattern matching ;) )

@Gabriel439 Gabriel439 merged commit 32aa2a7 into dhall-lang:master May 1, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@Gabriel439

This comment has been minimized.

Show comment
Hide comment
@Gabriel439

Gabriel439 May 1, 2017

Collaborator

Awesome! Thank you for contributing this :)

Collaborator

Gabriel439 commented May 1, 2017

Awesome! Thank you for contributing this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment