Conversation
added 5 commits
August 26, 2020 10:09
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.
added 2 commits
August 26, 2020 20:22
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.
added 10 commits
September 20, 2020 13:09
added 6 commits
September 28, 2020 10:56
Contributor
Author
|
I have implemented the last few suggestions now, but I have also incorporated a few changes into this pull request that were originally required by #202. However, implementing some of the suggestions on what would have essentially been an outdated version of the instance generation would not have made sense. Therefore, those changes have now been added here. Specifically, the |
MarvinLira
approved these changes
Sep 28, 2020
Daniel-Teut
approved these changes
Sep 29, 2020
just95
approved these changes
Sep 29, 2020
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 #150
Closes #151
Description of the Change
The compiler now generates
NormalformandShareableArgsinstances for user-defined data types.In order to properly handle a program, it needs to be normalized first so that handlers do not have to consider effects in the components of data structures.
To be able to perform this normalization, a data type (and its argument types) must have a
Normalforminstance.Furthermore, the
shareoperator requires that the type of the computation that is shares has aShareableArgsinstance so its components can be shared.NormalformandShareableArgsinstances exist for all Prelude types, but users will also define their own Haskell data types. Therefore, the compiler needs to generate these instances for user-defined data types.Verification Process
Tests verifying the functionality of generated
Normalforminstances for various types have been added to theexamplefolder by @marvin2706. Additional functions and tests have been added (in the same modules) to test the generatedShareableArgsinstances.Additional Notes
Because the generation of induction schemes has been moved into its own module, there will likely be merge conflicts with #206.