Last active
June 4, 2023 13:16
-
-
Save mheiber/b9822b996c541519af349a26f2b74019 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
#!/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