-
Notifications
You must be signed in to change notification settings - Fork 53
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
Labelled effects #354
Merged
Merged
Labelled effects #354
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
…dependent effect.
patrickt
approved these changes
Mar 3, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic work, @robrix. I’m really excited that labelled effects were such a small addition in terms of API, because the advancements in expressivity are quite profound compared to the dummy-newtype approach.
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.
This PR defines a module for labelled effects, allowing some pretty powerful patterns applying injectivity/type dependencies to effects. For example:
Stock effects such as
Reader
andState
can be distinguished by means of arbitrary labels, which can be much more convenient thanScopedTypeVariables
in many cases.Type inference can be improved by the same means for many parametric effects if and as desired.
Effect parameters can be made dependent on the carrier without concretely mentioning it; this amounts to the ability to associate arbitrary types with effects via a label.
Equivalently, ambiguities can be resolved for effect parameters via a label.
Labels offer a super flexible means of applying injectivity to uniquely determine some effect from an arbitrary label, without having to define new classes anywhere; indeed, existing effects, operations, and carriers can be lifted into their labelled counterparts as-is.
This is in quite good shape for use, but there’s still some work to do before we merge this:
Reader
/State
operations?Laws? What would they even look like…?This isn’t really meaningful beyond the labelledReader
/State
operations.Control.Effect.Reader.Labelled
andControl.Effect.State.Labelled
.Hackage release.Going to do this in a separate PR after Benchmark Reader and inline its requests. #347 is in.