Created
April 22, 2020 05:22
-
-
Save CrowdHailer/7c3cc1c1542f7c513a201c9ceac53449 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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