Skip to content

Instantly share code, notes, and snippets.

@hcarty
Created August 29, 2013 15:18
Show Gist options
  • Save hcarty/6379435 to your computer and use it in GitHub Desktop.
Save hcarty/6379435 to your computer and use it in GitHub Desktop.
Modules from modules
module type S = sig
type t
end
module type Sout = sig
type a
type b
type t = A of a | B of b
end
let make : type ta tb. (module S with type t = ta) -> (module S with type t = tb) -> (module Sout with type a = ta) =
fun (module Ma) (module Mb) ->
let module Mab =
struct
type a = Ma.t
type b = Mb.t
type t = A of Ma.t | B of Mb.t
end
in
let m = (module Mab : Sout with type a = Ma.t) in
m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment