Skip to content

Instantly share code, notes, and snippets.

@gsg
Created March 20, 2015 15:42
Show Gist options
  • Save gsg/9ffcae2f7e754084df10 to your computer and use it in GitHub Desktop.
Save gsg/9ffcae2f7e754084df10 to your computer and use it in GitHub Desktop.
module type CON = sig
type 'a t
val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b t -> 'a
end
(* (stdlib) List doesn't include 'a t, add it *)
module ListT = struct
type 'a t = 'a list
include List
end
module Test1 (M : CON) : CON = struct
include M
end
module L1 = Test1 (ListT)
(* Would not type check *)
(* let _ = L1.fold_left (+) 0 [] *)
module Test2 (M : CON) : CON with type 'a t = 'a M.t = struct
include M
end
module L2 = Test2 (ListT)
let _ = L2.fold_left (+) 0 []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment