Created
December 1, 2014 15:39
-
-
Save ramntry/91448cefe05fed73fc6a 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
module type List = sig | |
type a | |
type t | |
val nil : t | |
val cons : a -> t -> t | |
val switch : (unit -> 'b) -> (a -> t -> 'b) -> t -> 'b | |
end | |
let to_string (type e) (type s) (module Impl : List with type a = e and type t = s) string_of_item l = | |
let rec inner ys = | |
Impl.switch | |
(fun () -> "") | |
(fun x xs -> string_of_item x ^ " " ^ inner xs) | |
ys | |
in | |
inner l |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment