Comments (1)
Thanks!
Send/receive strikes me as a central feature for Erlang ("receive" is actually a part of the Core Erlang AST) and I wanted to work towards supporting all of those so that people would be able to use MLFE itself for as many things as possible. Missing items like try, catch, and error are all on my short-term TODO list with things like links in the medium term.
When it comes to OTP functionality like gen_server we actually need parameterized modules and an improved FFI to type properly. At a bare minimum we'd need things like parametric interfaces (like a very restrictive ML signature) that modules can implement and FFI extensions to type the server returned. I think this will unfortunately require a handful of explicit type annotations (at least for the interface) but it seems a small price to pay for an even more lightweight FFI with no Erlang code necessary to bridge it. A half-baked and potentially problem-laden interface might look like the following:
interface minimal_gen_server 'state 'messages 'replies
type call_result = (reply, 'replies, 'state) | (noreply, 'state)
init 'b: 'b -> (ok, 'state)
handle_call: 'messages -> pid _ -> 'state -> call_result
Where something like the FFI bridge for gen_server:start
might look like:
type gen_server 'messages 'replies = GenServer pid 'messages
start 'a 'b 'c: minimal_gen_server 'a 'b 'c -> 'a -> gen_server 'b 'c
bridge start mod init = match gen_server.start(mod, init, []) with
(ok, pid) -> GenServer pid
Here bridge
would entail a fair bit of unification and I'm sure there are buckets of problems, not least of which is we're not actually capturing the 'replies
type in that gen_server
ADT properly but this is all off the cuff :)
from alpaca.
Related Issues (20)
- Function parsing as incorrect arity with ADT as first arg HOT 2
- Auto-imported pipe operator HOT 2
- Treat types with a single unqualified member as aliases HOT 1
- Overlap between function heads and match expression HOT 1
- How to type Erlang terms without built-in types. HOT 7
- alias module name HOT 1
- Zero arity functions HOT 5
- Inconsistent function case HOT 2
- Compile error with type signature annotation
- Defining the function (>>) does not yield a helpful error
- Use values to signify test pass/fail rather than exceptions
- Can't find a way to contact the creator/mantainers of alpaca :) HOT 2
- ReasonML HOT 4
- provide prebuilt "binaries" for OTP 21
- Status? HOT 4
- "Overloaded" records with constructors in patterns fail instead of getting a proper warning.
- Incorrect line numbers for missing record field errors
- clarify - nominal or structural type system HOT 3
- ADT argument in function header crashes compiler
- Non-exhaustive patterns in "match" expressions 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 alpaca.