-
Notifications
You must be signed in to change notification settings - Fork 108
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't scan with a body that has an effect #1133
Comments
I know this problem can be worked around by just hand-inlining the definition of I know that for the state effect it can also be worked around by including the external state I want to carry in the scan's carries, but (i) that also seems lame; (ii) it will cause extra copies if I don't actually update the external state in every iteration; and (iii) it loses information if the external effect is accum rather than state, and doesn't work at all if the external effect is IO or something like that. |
I discussed this offline with @xnning and she helped me understand the problem. The effect rules we use during inference, which are stricter than the ones we use during checking, work as follows. Given some effect context,
The effect of Why do we have this funny rule? It was my attempt at adapting Koka's rules, particularly see Section 2.3 of Daan Leijen's row-polymorphic effect types paper. The advantage of this system, versus something that models bags of effects more directly, is that it almost gives you the behavior of "you get to use any subset of the allowed effects" but without having to deal with inequality constraints during inference. Note that our type checking rules, i.e. Where does this leave us with the But maybe we should rethink the effect rows altogether? One big different between Dex and Koka is that we're very to have explicit effect annotations on functions. If we relax the requirements on type inference and ask users to be more explicit maybe a bag-of-effects system can work? |
I thought I could write an expression that computes the first few squares like this:
But the body of
scan
is type-annotated to be pure, so I gotI could try to generalize scan, like so
but then I get this type error
Is that supposed to happen? Is there a good reason?
The text was updated successfully, but these errors were encountered: