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

move effect command from member type to type parameter #356

Merged
merged 1 commit into from
May 12, 2024

Conversation

fwbrasil
Copy link
Collaborator

@fwbrasil fwbrasil commented May 12, 2024

I'm working on a follow up of #348 to rely on the new Tag in Aborts. Something that has been challenging when developing effects is dealing with variance and the Command defined as type member:

class Aborts[-V] extends Effect[Aborts[V]]:
    type Command[T] = Left[V, ?] // compilation error because V is contravariant

This fails to compile because V is contravariant and type members are invariant. It's possible to work it around by making Command opaque but then it's necessary to provide bridge methods.

This PR changes the encoding of effects to use a type parameter for the command instead of a type member, which solves this encoding issue with variance.

@@ -10,6 +10,7 @@ val compilerOptions = Seq(
"-feature",
"-unchecked",
"-deprecation",
"-Ykind-projector",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it easier to define commands.

@@ -54,3 +49,12 @@ object Vars:
def run[V >: Nothing]: RunDsl[V] = new RunDsl[V]

end Vars

// Moving to Vars.internal crashes the compiler
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get a cyclic type error for Flat if I do this, which doesn't make much sense. It seems a compiler bug.

@fwbrasil
Copy link
Collaborator Author

I'm merging this to unblock other work but please feel free to provide feedback!

@fwbrasil fwbrasil merged commit 757a7ae into main May 12, 2024
3 checks passed
@fwbrasil fwbrasil deleted the effect-command branch May 12, 2024 16:58
@fwbrasil
Copy link
Collaborator Author

FYI This change introduced other complexities and didn't fully solve the variance issue. I've reverted it on main.

This pull request was closed.
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.

1 participant