Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module type Big = sig
- type t
- val v : t
- end
- module type Small = sig
- include Big
- val v' : t
- end
- let get_v (type a) (smol : (module Big with type t = a)) : a =
- let module M = (val smol) in
- M.v
- ;;
- let create () =
- ( module struct
- type t = int
- let v = 0
- let v' = 1
- end
- : Small
- with type t = int )
- ;;
- module Sub' : Small = (val create ())
- let _zero = get_v (module Sub')
- let _zero =
- let module M = (val create ()) in
- get_v (module M)
- ;;
- (** Why does the above work, but not this?: *)
- let _zero = get_v (create ())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement