Comments (12)
I believe this is due to a foolish design that we played around with years ago, but which still persists. The source language supports the escape
control operator, whereas the IR uses call/cc. The mismatch makes it difficult to properly support polymorphism. We might hope that the captured continuation y
be polymorphic, but it isn't.
An obvious fix is to synchronise the source language with the IR.
Ultimately, we might dispense with these control operators in favour of effect handlers.
from links.
Ultimately, we might dispense with these control operators in favour of effect handlers.
Is likely to happen anytime soon? escape
is still used in sendSuspend
and freshResource
which are used to deal with login flow; can this be implemented using effects/handlers now?
from links.
I think we should dispense of escape
in the source language now. As far as I can tell, we do not have a single example that makes use of escape
.
from links.
It is still used in the prelude, as mentioned above, and the sendSuspend
or freshResource
functions are used in loginFlow.links
and wine.links
.
from links.
Is there a particular reason not to just expose the IR's call/cc in the source language and use that instead?
from links.
Is there a particular reason not to just expose the IR's call/cc in the source language and use that instead?
Well, call/cc is not a modular abstraction. It is widely accepted that delimited continuations are superior to call/cc. See for example Oleg's an argument against call/cc.
from links.
Is there a reason to have call/cc in the IR instead of delimited continuations then?
from links.
Certainly if we have call/cc
in the IR then we should have call/cc
in the frontend as well. Alternatively we could have escape
in both.
If we can implement the sendSuspend
and freshResource
functionality using handlers then we can consider removing call/cc
. I suspect we probably can, by inserting some kind of outer handler, but we should do this before scrapping escape
/ call/cc
.
from links.
f we can implement the
sendSuspend
andfreshResource
functionality using handlers then we can consider removingcall/cc
.
I believe too we can achieve this by a similar idea to the one you outlined. An undelimited continuation is in some sense a delimited continuation whose delimiter is the top-level.
from links.
Is there a reason to have call/cc in the IR instead of delimited continuations then?
I don't think so, and we do already have a structured form of delimited continuations in terms of handlers.
from links.
This example:
{ escape y in { ("" == y(1), true == y(1)); 2 } }
should never have typechecked, because we should infer a single common return type for y
. If I had to guess, my guess would be that it was typechecking due to an idiosyncrasy of pre-FreezeML treatment of polymorphism type inference. It doesn't typecheck now.
<stdin>:1: Type error: The infix operator
`=='
has type
`(Bool, Bool) -a-> Bool'
while the arguments passed to it have types
`Bool'
and
`String'
and the currently allowed effects are
`wild'
In expression: true == y(1).
Fixing it to something that avoids this problem:
{ escape y in { ("" == y(1), "asdf" == y(1)); 2 } }
yields this, indicating that Links's treatment of semicolon expressions has also gotten stricter over time,
<stdin>:1: Type error: Side-effect expressions must have type `()', but the expression
`("" == y(1), "asdf" == y(1))'
has type
`(Bool, Bool)'
In expression: ("" == y(1), "asdf" == y(1));.
If we fix this by adding a var _
binding, then it typechecks and runs correctly.
links> { escape y in { var _ = ("" == y(1), "asdf" == y(1)); 2 } };
1 : Int
I don't immediately see a way of replicating the original problem, and am not sure that the original problem was anything directly to do with escape
or its differences with call/cc
, though I do think it is worthwhile to iron out this wrinkle. I will add/adjust the above test cases and close this.
from links.
I take the final remark about the original problem being nothing to do with the mismatch between escape/call/cc back: it seems from comments in typeSugar
:
Line 3501 in 0e3a7e5
that the original issue was due to generalizing the type of the escape continuation to "forall a. t -> a" (or, alternatively, "t -> forall a. a") which in the earlier approach to typechecking quantified types would allow the original program. We could still do this, but as the comment also observes, this would lead to a mismatch with call/cc
later anyway, so I think the current approach is appropriate until we decide on a rational design (such as implementing both escape and call/cc, or their use cases, using handlers).
from links.
Related Issues (20)
- Error when calling non-closed local server functions HOT 7
- Unbound effect variables in type aliases when effect sugar is enabled
- Incorrect resolution of shadowed names in mutual blocks HOT 2
- "flat" and "nested" kinds for query results
- Lens refactor HOT 2
- Kind inference
- dateToInt -> intToDate does not roundtrip depending on time zone HOT 3
- Interaction between session-typed communication and effects is broken even without multi-shot continuations
- Incomplete rows can trigger an internal error
- Some questions about your work :) HOT 3
- REPL prompt disappears HOT 5
- "opam install links" doesn't produce linx executable in Ocaml 5.0.0 HOT 8
- Restriction of using row polymorphism for the effect system
- Recent versions of ppx_sexp_conv cause warnings in lens code
- Untypesettable session types
- Implement delegatable channels
- Rename links-mysql8 driver to links-mysql? HOT 2
- SPARQL improvements
- ppx_sexp_conv creates code triggering warning 40 HOT 3
- Incompatible with OCaml 4.08 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from links.