Skip to content

Instantly share code, notes, and snippets.

@gsg
Last active December 28, 2020 08:44
Show Gist options
  • Save gsg/51477444322d5276a24179100243732c to your computer and use it in GitHub Desktop.
Save gsg/51477444322d5276a24179100243732c to your computer and use it in GitHub Desktop.
module Runtime : sig
type 'a t
type t1
type t2
val foo : t1 t -> unit
val bar : _ t -> unit
val create1 : unit -> t1 t
val create2 : unit -> t2 t
end = struct
type 'a t = int
type t1 = [ `A ]
type t2 = [ `B ]
let create1 () = 42
let create2 () = 100500
let foo _ = ()
let bar _ = ()
end
module type Arg = sig
type runtime
val baz : runtime -> unit
end
module F (A:Arg) = struct let zzz rt = Runtime.bar rt; () end
module Arg1 = struct
type runtime = Runtime.t1 Runtime.t
let baz rt = Runtime.foo rt
end
module Arg1_applied = F (Arg1)
module Arg2 = struct
type runtime = Runtime.t2 Runtime.t
let baz rt = Runtime.bar rt
end
module Arg2_applied = F (Arg2)
module Arg_any = struct
type runtime = R : _ Runtime.t -> runtime [@@unboxed]
let baz (R rt) = Runtime.bar rt
end
module Arg_any_applied = F (Arg_any)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment