-
Notifications
You must be signed in to change notification settings - Fork 3
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
Encapsulate effects in QuickCheck function arguments #216
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
During the conversion of a data declaration, a Normalform instance will be generated. This commit implements a part of that generator that generates most of the nf' function. The resulting code is not yet valid because the type signature is still missing, but if the type signature is added manually, the generated code is valid. We are able to consider types with nested recursion and mutually recursive types, but I have not considered type synonyms yet. That will also be added later.
The program to generate typeclass instances for user-defined Haskell types is now more general. Instances for different typeclasses can now be generated simply by passing a few parameters, namely: - The name of the class - The name of the function provided by the class - A function that generates appropriate binders and return types - A function that builds a concrete value of the return type Currently, only typeclass instances with a certain structure can be generated (for example, the class can currently only contain one function), but it should be quite easy to generate instances for ShareableArgs in addition to Normalform now.
Before the return type of a data constructor is unified with a type expression, all variables (underscores) in the type expression are replaced with fresh variables to prevent unification failures. Additionally, the naming of the instance and top-level functions is now done outside of a local environment so that those names are registered globally and no name clashes can occur. Local functions and variables are still named inside a local environment.
Cherry picked from 7cf8a24.
Generate typeclass instances
MajaRet
added
the
pipeline
Related to the compiler pipeline (e.g. compiler passes or the command line interface)
label
Sep 29, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
pipeline
Related to the compiler pipeline (e.g. compiler passes or the command line interface)
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
Closes #211
Description of the Change
Effects are now encapsulated in the arguments of QuickCheck functions.
Previously, for example, the following program
would have been transformed by the
SharingAnalysisPass
as follows.However, this led to
prop
becoming impure when thelet
s were transformed toshare
s and call-by-need evaluation was used. An impure property cannot be translated to a CoqProp
by the compiler, so it became unprovable.Instead, QuickCheck functions now encapsulate generated
let
bindings (created by theSharingAnalysisPass
or theFlattenExprPass
). So the function above is transformed toWith this, the property itself remains pure.
Explicit
let
s in a Haskell module are not modified. Neither are regular predicates, sop x = x == x
is still unprovable when translated to Coq. One way to mitigate this somewhat would be to write a property
prop_p x1 ... xn = p x1 ... xn === True
for a predicatep
that takesn
arguments, or to write a lemma manually in Coq that handlesp
.