Commits

Anonymous committed 30b4963

List.ti construction

  • Participants
  • Parent commits 60b21bf

Comments (0)

Files changed (2)

             match (uget_exn self ub) with
             [ [] -> ti_variant vnil [| |]
             | [h :: t] -> ti_variant vcons [| ubox ti_elem h ; ubox self t |]
-            ])
-            [| |] (* todo: list construction here *)
+            ]
+            )
+            [| ( "List.nil"
+               , [| |]
+               , fun
+                 [ [| |] -> ubox self []
+                 | _ -> assert False
+                 ]
+               )
+             ; ( "List.cons"
+               , [| (ti_elem :> Cdt.uti) ; (self :> Cdt.uti) |]
+               , fun
+                 [ [| h ; t |] -> ubox self
+                     [uget_exn ti_elem h :: uget_exn self t]
+                 | _ -> assert False
+                 ]
+               )
+             |]
           in fun
           [ "cmp" -> proc "List.0" "List.1"
           | _ -> proc "List.nil" "List.cons"
 type ctr_var 'z = (variant_name * array uti * (array ubox -> 'z))
 ;
 
+value ti_ctr_variant0
+ : variant_name -> 'z -> ctr_var 'z
+ = fun vn ctr0 ->
+     ( vn
+     , [| |]
+     , fun
+       [ [| |] -> ctr0
+       | _ -> assert False
+       ]
+     )
+;
+
 value ti_ctr_variant1
  : variant_name -> ti 'a -> ('a -> 'z) -> ctr_var 'z
  = fun vn tia ctr1 ->