Skip to content
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 99 commits into from
Mar 3, 2020
Merged

Labelled effects #354

merged 99 commits into from
Mar 3, 2020

Conversation

robrix
Copy link
Contributor

@robrix robrix commented Feb 7, 2020

This PR defines a module for labelled effects, allowing some pretty powerful patterns applying injectivity/type dependencies to effects. For example:

  1. Stock effects such as Reader and State can be distinguished by means of arbitrary labels, which can be much more convenient than ScopedTypeVariables in many cases.

  2. Type inference can be improved by the same means for many parametric effects if and as desired.

  3. 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.

  4. 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:

  • API documentation.
  • Document the sorts of patterns this enables; e.g. how to solve interesting inference or ambiguity problems.
  • Maybe bake in labelled Reader/State operations?
  • Changelog entry.
  • Tests.
  • Laws? What would they even look like…? This isn’t really meaningful beyond the labelled Reader/State operations.
  • Changelog entries for Control.Effect.Reader.Labelled and Control.Effect.State.Labelled.
  • Hackage release. Going to do this in a separate PR after Benchmark Reader and inline its requests. #347 is in.

@robrix robrix mentioned this pull request Mar 3, 2020
5 tasks
@robrix robrix added this to the 1.0.2.0 milestone Mar 3, 2020
@robrix robrix marked this pull request as ready for review March 3, 2020 12:27
Copy link
Collaborator

@patrickt patrickt left a 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.

@robrix robrix merged commit 5bf061d into master Mar 3, 2020
@robrix robrix deleted the label-maker branch March 3, 2020 12:35
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.

None yet

2 participants