Anonymous avatar Anonymous committed 30b4963

List.ti construction

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 ->
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.