Skip to content

Instantly share code, notes, and snippets.

@ELLIOTTCABLE
Last active January 29, 2019 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ELLIOTTCABLE/1fc5d8bb923a61ef5592de172b06a489 to your computer and use it in GitHub Desktop.
Save ELLIOTTCABLE/1fc5d8bb923a61ef5592de172b06a489 to your computer and use it in GitHub Desktop.
module type AType = sig
type t
end
module type CBAO = sig
type a
type ret
val call : (a -> ret) -> a -> ret
end
module Base (A : AType) : CBAO = struct
type a = A.t
type ret = unit
let call (f : a -> ret) (a : a) = f a
end
module rec AppliesTo : functor (A : AType) -> (functor (Ret : CBAO) -> CBAO) =
functor (A : AType) -> functor (Ret : CBAO) -> struct
type a = A.t
type ret = (Ret.a -> Ret.ret)
let call (f : a -> ret) (a : a) = f a
end;;
module M : AType with type t = int = struct type t = int end
module N : AType with type t = string = struct type t = string end
module X : CBAO = Base(M)
let g (_i : int) = ();;
X.call
g
1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment