Skip to content

Instantly share code, notes, and snippets.

@mheiber
Last active June 4, 2023 13:16
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 mheiber/b9822b996c541519af349a26f2b74019 to your computer and use it in GitHub Desktop.
Save mheiber/b9822b996c541519af349a26f2b74019 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ocaml
module type HdArg = sig
type t
val x: t list
val continuation : t -> unit
end
let hd (module M : HdArg): unit =
let fn : M.t list -> M.t = function
| h :: _ -> h
| _ -> failwith "got 0-length list"
in
M.continuation (fn M.x)
let () =
let module M : HdArg = struct
type t = int
let x = [1; 2; 3]
let continuation = Printf.printf "result: %d\n"
end
in
hd (module M)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment