Skip to content

Instantly share code, notes, and snippets.

@stedolan
Created September 1, 2021 12:38
Show Gist options
  • Save stedolan/d07202b63559fb903d789246591f38f4 to your computer and use it in GitHub Desktop.
Save stedolan/d07202b63559fb903d789246591f38f4 to your computer and use it in GitHub Desktop.
module type T = sig
type t
end
module type S = sig
type t
module Map : Map.S with type key = t
module Set : Set.S with type elt = t
module Tbl : Hashtbl.S with type key = t
end
module Make (X : T) = struct
module Map = Map.Make (struct type t = X.t let compare = compare end)
module Set = Set.Make (struct type t = X.t let compare = compare end)
module Tbl = Hashtbl.Make (struct type t = X.t let hash = Hashtbl.hash let equal = (=) end)
end
module Pair (X : T) = struct
module type With_Str_S = S with type t = X.t * string
module With_Str : With_Str_S = struct
type t = X.t * string
include Make (struct type nonrec t = t end)
end
module type With_Int_S = S with type t = X.t * int
module With_Int : With_Int_S= struct
type t = X.t * int
include Make (struct type nonrec t = t end)
end
module type With_Float_S = S with type t = X.t * float
module With_Float : With_Float_S = struct
type t = X.t * float
include Make (struct type nonrec t = t end)
end
module type With_Int32_S = S with type t = X.t * int32
module With_Int32 = struct
type t = X.t * int32
include Make (struct type nonrec t = t end)
end
module type With_Int64_S = S with type t = X.t * int64
module With_Int64 : With_Int64_S = struct
type t = X.t * int64
include Make (struct type nonrec t = t end)
end
module type With_Nativeint_S = S with type t = X.t * nativeint
module With_Nativeint = struct
type t = X.t * nativeint
include Make (struct type nonrec t = t end)
end
end
module M = struct
module IntPair = Pair (struct type t = int end)
module StrPair = Pair (struct type t = string end)
module FloatPair = Pair (struct type t = float end)
end
module Big1 = struct
module A = struct include M end
module B = struct include M end
module C = struct include M end
module D = struct include M end
module IntPair = Pair (struct type t = int end)
module StrPair = Pair (struct type t = string end)
module FloatPair = Pair (struct type t = float end)
module type T = module type of M
let n = 5
end
module Big2 = struct
module A = struct include M end
module B = struct include M end
module C = struct include M end
module D = struct include M end
module IntPair = Pair (struct type t = int end)
module StrPair = Pair (struct type t = string end)
module FloatPair = Pair (struct type t = float end)
module type T = module type of M
let n = 5
end
module Big3 = struct
module A = struct include M end
module B = struct include M end
module C = struct include M end
module D = struct include M end
module IntPair = Pair (struct type t = int end)
module StrPair = Pair (struct type t = string end)
module FloatPair = Pair (struct type t = float end)
module type T = module type of M
let n = 5
end
module Big4 = struct
module A = struct include M end
module B = struct include M end
module C = struct include M end
module D = struct include M end
module IntPair = Pair (struct type t = int end)
module StrPair = Pair (struct type t = string end)
module FloatPair = Pair (struct type t = float end)
module type T = module type of M
let n = 5
end
module Big5 = struct
module A = struct include M end
module B = struct include M end
module C = struct include M end
module D = struct include M end
module IntPair = Pair (struct type t = int end)
module StrPair = Pair (struct type t = string end)
module FloatPair = Pair (struct type t = float end)
module type T = module type of M
let n = 5
end
module Big6 = struct
module A = struct include M end
module B = struct include M end
module C = struct include M end
module D = struct include M end
module IntPair = Pair (struct type t = int end)
module StrPair = Pair (struct type t = string end)
module FloatPair = Pair (struct type t = float end)
module type T = module type of M
let n = 5
end
module Big7 = struct
module A = struct include M end
module B = struct include M end
module C = struct include M end
module D = struct include M end
module IntPair = Pair (struct type t = int end)
module StrPair = Pair (struct type t = string end)
module FloatPair = Pair (struct type t = float end)
module type T = module type of M
let n = 5
end
module Big8 = struct
module A = struct include M end
module B = struct include M end
module C = struct include M end
module D = struct include M end
module IntPair = Pair (struct type t = int end)
module StrPair = Pair (struct type t = string end)
module FloatPair = Pair (struct type t = float end)
module type T = module type of M
let n = 5
end
module Big9 = struct
module A = struct include M end
module B = struct include M end
module C = struct include M end
module D = struct include M end
module IntPair = Pair (struct type t = int end)
module StrPair = Pair (struct type t = string end)
module FloatPair = Pair (struct type t = float end)
module type T = module type of M
let n = 5
end
module A = Big1
module B = Big2
module C = Big3
module D = Big4
module E = Big5
module F = Big6
module G = Big7
module H = Big8
module I = Big9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment