-
Notifications
You must be signed in to change notification settings - Fork 20
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
Can I use polymorphic effects to de facto substitue monad transformers in some cases? #171
Comments
Hey! Thanks for reaching out :) First of all, let me try to respond to two things:
Indeed, this is our motivation. You can use effects to model optional results (like you did with effect
From your code it looks like you managed after all. Congratulations, this is a somewhat hidden feature :) Maybe discussing some more details of your code will further clarify some things.
I believe this is not doing what you think it does. The
Importantly,
and not for
I slightly rewrote your example to be a bit more "Effekt-idiomatic": Notice how A more detailed implementation of async await has been given in another example: |
Thank you! I hoped for something exactly like this. |
Oh. I just noticed that it returned 0, but as far as I understand it should return 1... Why is there a 0? |
In the example I handle the effect by always aborting with the value 0. You can try to replace |
Thank you! That makes sense. Can I somehow cast to type A or reason about it in await (in your snippet)? Do you have any idea on how to make this code resume with 0 as A? (or some other solution that makes it work, but keeping it generic, if you can think of something else). I am trying to implement this. |
Hey, for the given type of You can change the effect signature to
For a very simple implementation of https://github.com/effekt-lang/effekt/blob/master/libraries/js/monadic/io/async.effekt |
I'm gonna close the issue. Let me know if I can be of any more help :) |
Sure! Thank you for all your help. |
I had a couple of attempts on using polymorphic effects to make an interesting approach at polymorphy:
I think that with this snippet you can see what I was aiming at. I want to make the
doStuff
function capable of performing operations without knowing what are the details ofelements
- such as the fact that they are computed asynchronously or are optional. I came to the problem that effects can't have lambdas as parameters in any way. Neither in their own params, nor in the function parameters. Is there a way to go around that and achieve something similar to what I was aiming at?My general goal is to investigate if polymorphic effects can be use to achieve something similiar to monad transformers. It would be great to have a code unaware of the real "context" of execution. Did you perform any research in that area?
The text was updated successfully, but these errors were encountered: