diff options
author | Jacques Garrigue <garrigue at math.nagoya-u.ac.jp> | 2002-01-05 06:55:22 +0000 |
---|---|---|
committer | Jacques Garrigue <garrigue at math.nagoya-u.ac.jp> | 2002-01-05 06:55:22 +0000 |
commit | c8edf6a3efb7c93fe9c3e86b4d7ffa8064ff2be5 (patch) | |
tree | 35058e189e425cac11ed6c7dad1ca614dbbc8f98 | |
parent | 0bd264afd1259a9359cac4240d46e863c05812bf (diff) | |
download | ocaml-unlabeled-1.3.2.tar.gz |
merci Alainunlabeled-1.3.2
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/unlabeled-1.3.2@4230 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | testlabl/poly.ml | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/testlabl/poly.ml b/testlabl/poly.ml index e243799663..0ad4aeb75e 100644 --- a/testlabl/poly.ml +++ b/testlabl/poly.ml @@ -1,9 +1,11 @@ (* my own tests *) - open StdLabels;; -type 'a t = { t : 'a } -;; +type 'a t = { t : 'a };; +type 'a fold = { fold : 'b. f:('b -> 'a -> 'b) -> init:'b -> 'b };; +let f l = { fold = List.fold_left l };; +(f [1;2;3]).fold ~f:(+) ~init:0;; + class ['b] ilist l = object val l = l method add x = {< l = x :: l >} @@ -96,6 +98,10 @@ class vari = object method m = function `a -> 1 | _ -> 0 end ;; +class vari = object + method m : 'a. ([< `a|`b|`c] as 'a) -> int = function `a -> 1 | _ -> 0 +end +;; module V = struct type v = [`a | `b | `c] @@ -107,6 +113,23 @@ class varj = object method m = V.m end ;; + +module type T = sig + class vari : object method m : 'a. ([< `a | `b | `c] as 'a) -> int end +end +;; +module M0 = struct + class vari = object + method virtual m : 'a. ([< `a|`b|`c] as 'a) -> int + method m = function `a -> 1 | _ -> 0 + end +end +;; +module M : T = M0 +;; +let v = new M.vari;; +v#m `a;; + class point ~x ~y = object val x : int = x val y : int = y |