diff options
| author | Jacques Garrigue <garrigue at math.nagoya-u.ac.jp> | 2009-10-26 03:42:22 +0000 |
|---|---|---|
| committer | Jacques Garrigue <garrigue at math.nagoya-u.ac.jp> | 2009-10-26 03:42:22 +0000 |
| commit | 7a3172be17d01a659c8fec3ee8d144b7b2295b57 (patch) | |
| tree | b8bcee4644617af48728cff5bc84738cf4378d14 | |
| parent | d494593cb958aafc014ac67a2b8eaaf6bcca1829 (diff) | |
| download | ocaml-class-with-type.tar.gz | |
more examplesclass-with-type
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/class-with-type@9395 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
| -rw-r--r-- | testlabl/classwithtype.ml | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/testlabl/classwithtype.ml b/testlabl/classwithtype.ml index 28eeeabb23..1d959b341f 100644 --- a/testlabl/classwithtype.ml +++ b/testlabl/classwithtype.ml @@ -43,6 +43,13 @@ end = struct type ('a,'b) sub_control = SubControl of 'a control constraint 'b = int end +module rec TC : sig + class type ['a] control = object + method sub: 'b. ('a, 'b) type_path -> ('b,int) TC.sub_control + end + type ('a,'b) sub_control = SubControl of 'a control constraint 'b = int +end = TC + (* Oops, recursive module didn't propagate variance correctly. Work now with explicit variances. *) module rec A : sig @@ -109,3 +116,21 @@ end let l = new olist [1;2;3] let Olist.W l' = l#map float let l'' = l#map_self succ + +type 'a get_n = 'b constraint 'a = <n : 'b; ..> + +class type c = object method m : t method n : int end +with type t = c get_n + +module rec M : sig + type t = M.c get_n + class type c = object method m : t method n : int end +end = struct + type t = M.c get_n + class type c = object method m : t method n : int end +end + +module rec M : sig + class type c = object method m : M.t method n : int end + type t = c get_n +end = M |
