Skip to content

Instantly share code, notes, and snippets.

@CrowdHailer
Created April 22, 2020 05:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CrowdHailer/7c3cc1c1542f7c513a201c9ceac53449 to your computer and use it in GitHub Desktop.
Save CrowdHailer/7c3cc1c1542f7c513a201c9ceac53449 to your computer and use it in GitHub Desktop.
pub type Worker(m) {
Pid
}
pub type WorkerMessage(m) {
Down
Message(m)
}
pub type Worker(m) {
Pid
}
pub type WorkerMessage(m) {
Down
Message(m)
}
pub fn spawn(init: fn(fn() -> WorkerMessage(m)) -> Nil) -> Result(Worker(m), Nil) {
Ok(Pid)
}
pub fn send(pid: Worker(m), message: m) -> Result(Nil, Nil) {
Ok(Nil)
}
fn example() {
let Ok(pid) = spawn(fn(receive) {
let Message(5) = receive()
// Won't compile because receive is a fn that returns integer
// let Message("String") = receive()
Nil
})
send(pid, 900)
// Won't compile because pid is paramaterised by i
send(pid, "String")
Nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment