Oversimplified, but possibly enough to make it more readable: It's a bit like the (rust) enum syntax, but used for more stuff. So the type Program bit might translate to (something like, since this won't work as-is):
enum Program {
End,
Work { x: i64, y: Program },
Spawn { x: Program, y: Pid },
Send { x:Pid, y: String, z: Program },
Receive {x: String, y: Program },
Crash,
Link {x: Pid, y: Program },
}
Then you've got the bits where variables of those enum types are assigned. So this:
ex2 : Program
ex2 =
Work 5 <| \() ->
End
Is like:
let ex2 = Program::Work { x: 5,
y: Program::End };
Then the rest is case statements (like match statements), and code organized in a way similar to the variable declarations.
The syntax is crazy unreadable for me as a C, Rust, Go user. I honestly cant grasp the snippets fully
Learning a bit of ocaml or Haskell will help with that
Oversimplified, but possibly enough to make it more readable: It's a bit like the (rust)
enumsyntax, but used for more stuff. So thetype Programbit might translate to (something like, since this won't work as-is):Then you've got the bits where variables of those
enumtypes are assigned. So this:Is like:
Then the rest is
casestatements (likematchstatements), and code organized in a way similar to the variable declarations.Yeah, it's crazy how much syntax familiarity matters even when you know the concepts! Although I guess we have that with natural language, too.
Here is the Elm code from Example 2, with a short description above each function and a Rust translation below it. https://ellie-app.com/x5qfKP2nr8Za1
(And here is the Rust code on its own, since I wrote it anyway.) https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=edbe74894f2246941143912b2a75bab8
NB: I messed the Rust equivalent a bit by making the continuations take 1 dummy arg instead of zero args.
To write a function:
To call a function:
To write an anonymous function:
Defining an enum type:
Constructing an enum variant:
Thank you very much, it does make a lot more sense now
Yay! I'm glad I got to meet one of today's lucky 10 000 <3
Syntax is superficial.
its subjective, but it still matters id say
I hope some LLM is able to port the examples into C-like pseudocode for you. Rust should be close enough to Elm thanks to supporting ADTs.
Happy to discuss specific ideas/paragraphs/snippets to help understanding too.
This is very cool. Not sure what I would use this for but cool it is.
Impressive stuff! I look forward to reading it in detail, hopefully sometime soon.