Specifically, stack management in OCaml.
Maintaining esy
I helped them build a package manager and ship multi-platform builds
Again devtools and a core economic protocol proposal
And hopefully develop an open source template for other companies to follow.
with Hindley Milner type system
Like Haskell, but closer to metal.
open Angstrom
let parens p = char '(' *> p <* char ')'
let add = char '+' *> return (+)
let sub = char '-' *> return (-)
let mul = char '*' *> return ( * )
let div = char '/' *> return (/)
let integer =
take_while1 (function '0' .. '9' -> true | _ -> false) >>| int_of_string
Like Javascript and Lisps. Unlike Haskell.
let addProjectToGCRoot = (proj: Project.t) => {
let prefixPath =
switch (proj.projcfg.prefixPath) {
| Some(prefixPath) => prefixPath
| None => EsyBuildPackage.Config.storePrefixDefault
};
let currentProjectPath = Path.show(proj.projcfg.path);
EsyFetch.ProjectList.sync(prefixPath, currentProjectPath);
};
class stack_of_ints = {
as self;
val mutable theList: list(int) = []; /* instance variable */
pub push = x =>
/* push method */
theList = [x, ...theList];
pub pop =
{
let result = List.hd(theList);
theList = List.tl(theList);
result;
} /* pop method */;
pub peek =
List.hd(theList) /* peek method */;
pub size =
List.length(theList) /* size method */;
};
I was studying OCaml's DWARF output
try {
// validation, processing, lot of code
// oops
throw new Error("Ignoring rest of code and jumping to the handler")
// What?! You're saying, with effects, the code can resume here?
} catch(e) {
// handle the error
}
type _ Effect.t += Hello : unit Effect.t
let main () =
Effect.perform Hello
let () =
let retc = Fun.id in
let exnc = raise in
let effc : type c. c Effect.t -> ((c, 'a) Effect.Deep.continuation -> 'a) option
= function
| Hello -> Some (fun k -> print_endline "Hello"; Effect.Deep.continue k ())
| _ -> None
in
Effect.Deep.match_with main () { retc; exnc; effc }
let () =
let failing_fn () =
failwith "This function failed"
in
let fn_c () =
failing_fn ()
in
let fn_b () =
fn_c ()
in
let fn_a () =
fn_b ()
in
try fn_a () with | e -> raise e
let () =
let failing_fn () =
failwith "This function failed"
in
let fn_c () =
failing_fn ()
in
let fn_b () =
fn_c ()
in
let fn_a () =
fn_b ()
in
try fn_a () with | e -> raise e
let () =
let failing_fn () =
failwith "This function failed"
in
let fn_c () =
failing_fn ()
in
let fn_b () =
fn_c ()
in
let fn_a () =
fn_b ()
in
try fn_a () with | e -> raise e
let () =
let failing_fn () =
failwith "This function failed"
in
let fn_c () =
failing_fn ()
in
let fn_b () =
fn_c ()
in
let fn_a () =
fn_b ()
in
try fn_a () with | e -> raise e
let () =
let failing_fn () =
failwith "This function failed"
in
let fn_c () =
failing_fn ()
in
let fn_b () =
fn_c ()
in
let fn_a () =
fn_b ()
in
try fn_a () with | e -> raise e
let () =
let failing_fn () =
failwith "This function failed"
in
let fn_c () =
failing_fn ()
in
let fn_b () =
fn_c ()
in
let fn_a () =
fn_b ()
in
try fn_a () with | e -> raise e
let () =
let effectful_fn () =
let effect_result = perform Some_effect in
// some work with effect_result
in
let fn_c () =
effectful_fn ()
in
let fn_b () =
fn_c ()
in
let fn_a () =
fn_b ()
in
try fn_a () ; fn_c () with
| effect e, k -> continue k
let () =
let effectful_fn () =
let effect_result = perform Some_effect in
// some work with effect_result
in
let fn_c () =
effectful_fn ()
in
let fn_b () =
fn_c ()
in
let fn_a () =
fn_b ()
in
try fn_a () ; fn_c () with
| effect e, k -> continue k
let () =
let effectful_fn () =
let effect_result = perform Some_effect in
// some work with effect_result
in
let fn_c () =
effectful_fn ()
in
let fn_b () =
fn_c ()
in
let fn_a () =
fn_b ()
in
try fn_a () ; fn_c () with
| effect e, k -> continue k
let () =
let effectful_fn () =
let effect_result = perform Some_effect in
// some work with effect_result
in
let fn_c () =
effectful_fn ()
in
let fn_b () =
fn_c ()
in
let fn_a () =
fn_b ()
in
try fn_a () ; fn_c () with
| effect e, k -> continue k
let () =
let effectful_fn () =
let effect_result = perform Some_effect in
// some work with effect_result
in
let fn_c () =
effectful_fn ()
in
let fn_b () =
fn_c ()
in
let fn_a () =
fn_b ()
in
try fn_a () ; fn_c () with
| effect e, k -> continue k
let () =
let effectful_fn () =
let effect_result = perform Some_effect in
// some work with effect_result
in
let fn_c () =
effectful_fn ()
in
let fn_b () =
fn_c ()
in
let fn_a () =
fn_b ()
in
try fn_a () ; fn_c () with
| effect e, k -> continue k
let () =
let effectful_fn () =
let effect_result = perform Some_effect in
// some work with effect_result
in
let fn_c () =
effectful_fn ()
in
let fn_b () =
fn_c ()
in
let fn_a () =
fn_b ()
in
try fn_a () ; fn_c () with
| effect e, k -> continue k
let () =
let effectful_fn () =
let effect_result = perform Some_effect in
// some work with effect_result
in
let fn_c () =
effectful_fn ()
in
let fn_b () =
fn_c ()
in
let fn_a () =
fn_b ()
in
try fn_a () ; fn_c () with
| effect e, k -> continue k
let () =
let effectful_fn () =
let effect_result = perform Some_effect in
// some work with effect_result
in
let fn_c () =
effectful_fn ()
in
let fn_b () =
fn_c ()
in
let fn_a () =
fn_b ()
in
try fn_a () ; fn_c () with
| effect e, k -> continue k
let () =
let effectful_fn_2 () =
let effect_result = perform Some_effect in
// some work with effect_result
in
let effectful_fn_1 () =
effectfule_fn_2 ()
in
let fn_c () =
try effectful_fn () with
| effect e, k -> continue k
in
let fn_b () =
fn_c ()
in
let fn_a () =
fn_b ()
in
fn_a()
let () =
let effectful_fn_2 () =
let effect_result = perform Some_effect in
// some work with effect_result
in
let effectful_fn_1 () =
effectfule_fn_2 ()
in
let fn_c () =
try effectful_fn () with
| effect e, k -> continue k
in
let fn_b () =
fn_c ()
in
let fn_a () =
fn_b ()
in
fn_a()
let () =
let effectful_fn_2 () =
let effect_result = perform Some_effect in
// some work with effect_result
in
let effectful_fn_1 () =
effectfule_fn_2 ()
in
let fn_c () =
try effectful_fn () with
| effect e, k -> continue k
in
let fn_b () =
fn_c ()
in
let fn_a () =
fn_b ()
in
fn_a()
let () =
let effectful_fn_2 () =
let effect_result = perform Some_effect in
// some work with effect_result
in
let effectful_fn_1 () =
effectfule_fn_2 ()
in
let fn_c () =
try effectful_fn () with
| effect e, k -> continue k
in
let fn_b () =
fn_c ()
in
let fn_a () =
fn_b ()
in
fn_a()
let () =
let effectful_fn_2 () =
let effect_result = perform Some_effect in
// some work with effect_result
in
let effectful_fn_1 () =
effectfule_fn_2 ()
in
let fn_c () =
try effectful_fn_1 () with
| effect e, k -> continue k
in
let fn_b () =
fn_c ()
in
let fn_a () =
fn_b ()
in
fn_a()
let () =
let effectful_fn_2 () =
let effect_result = perform Some_effect in
// some work with effect_result
in
let effectful_fn_1 () =
effectfule_fn_2 ()
in
let fn_c () =
try effectful_fn_1 () with
| effect e, k -> continue k
in
let fn_b () =
fn_c ()
in
let fn_a () =
fn_b ()
in
fn_a()
let () =
let effectful_fn_2 () =
let effect_result = perform Some_effect in
// some work with effect_result
in
let effectful_fn_1 () =
effectfule_fn_2 ()
in
let fn_c () =
try effectful_fn_1 () with
| effect e, k -> continue k
in
let fn_b () =
fn_c ()
in
let fn_a () =
fn_b ()
in
fn_a()
More notes on ocaml-internals.dining-philosophers.dev
I'm @ManasJayanth on x.com.
You can email me at hello [at] manas-jayanth [dot] com
These slides can be found at slides.manas-jayanth.com