Commits

Anonymous committed f955e93

Cdt.ti_option* -> Option.ti*

  • Participants
  • Parent commits 30b4963

Comments (0)

Files changed (3)

File src/cd_Option.ml

       ]
     ;
 
+    value some x = Some x;
+    value none = None;
+
+
+    open Cdt;
+
+    class ti ['z]
+      (ti_a : #Cdt.ti 'a)
+      ()
+     =
+         ti_sum_type ['z]
+           ~constr:
+             [| ti_ctr_variant0 "None" none
+              ; ti_ctr_variant1 "Some" ti_a some
+              |]
+           (fun
+            [ None -> ti_variant "None" [| |]
+            | Some a -> ti_variant "Some" [| ubox ti_a a |]
+            ]
+           )
+    ;
+
+
+    class ti_hiding ['z]
+      (ti_a : #Cdt.ti 'a)
+      ()
+     =
+         ti_sum_type ['z]
+           ~constr:
+             [| ti_ctr_variant0 "None" none
+              ; ti_ctr_variant1 "Some" ti_a some
+              |]
+           (fun
+            [ None -> ti_variant "None" [| |]
+            | Some a -> ti_variant_dispatch "Some" (fun
+                [ "show" -> [| ubox ti_string_literal "<hidden>" |]
+                | _ -> [| ubox ti_a a |]
+                ])
+            ]
+           )
+    ;
+
+
   end
 ;
 (***********************************************)
 
 
-value ti_option
- : #ti 'a -> #ti (option 'a)
- = fun ti_a ->
-     new ti_sum_type
-       (fun
-        [ None -> ti_variant "None" [| |]
-        | Some a -> ti_variant "Some" [| ubox ti_a a |]
-        ]
-       )
-;
-
-
-value ti_option_hiding
- : #ti 'a -> #ti (option 'a)
- = fun ti_a ->
-     new ti_sum_type
-       (fun
-        [ None -> ti_variant "None" [| |]
-        | Some a -> ti_variant_dispatch "Some"
-            (fun [ "show" -> [| ubox ti_string_literal "<hidden>" |]
-                 | _ -> [| ubox ti_a a |]
-                 ]
-            )
-        ]
-       )
-;
-
-
-
 
 
 (*******************)

File test/test.ml

 open OUnit;
 open Printf;
 open Cd_All; open Cdt;
+open Cd_Option;
 
 module Cd = Cadastr;
 
 
 
 
-value my_ti_option_int = ti_option my_ti_int
+value my_ti_option_int = new Option.ti (my_ti_int :> ti _) ()
 ;
 
 
 
 
 value cdt_test5 () =
-  let my_ti_option_int_hiding = ti_option_hiding my_ti_int in
+  let my_ti_option_int_hiding = new Option.ti_hiding (my_ti_int :> ti _) () in
   ( cdt_tests_4_5 my_ti_option_int_hiding
   ; let test_data =
       [ (None, "None")