Last active
August 15, 2019 02:40
-
-
Save Pitometsu/bb75d86653ab01ee58b964ccc9be98e0 to your computer and use it in GitHub Desktop.
First-class modules sub-typing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module type C = sig type 'a t = [>`C|`D] as 'a end | |
module type D = sig include C with type 'a t = [>`D] as 'a end | |
module rec C : C = C;; | |
module rec D : D = D;; | |
type c_t = (module C);; | |
type d_t = (module D);; | |
(fun (m : c_t) -> (m :> d_t)) (module C);; | |
- : d_t = <module> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module type A = sig type a end;; | |
module type B = sig include A type b end;; | |
type a_t = (module A);; | |
type b_t = (module B);; | |
module A : A = struct type a = int end;; | |
module B : B = struct include A type b = string end;; | |
(fun (m : b_t) -> (m :> a_t)) (module B);; | |
- : a_t = <module> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Doh, that ARE NOT the depth value subtyping examples, rather... Kinda type covariance.
The, by value, in-depth subtyping:
Still not working