Handle list head and tail updates with explicit empty-list errors
This commit is contained in:
4 files changed
+26
No files matched your search
@@ -13,3 +13,15 @@ let compose (outer_get, outer_put) (inner_get, inner_put) =
|
||||
let _1 = (fun (left, _) -> left), (fun left (_, right) -> left, right)
|
||||
let _2 = (fun (_, right) -> right), (fun right (left, _) -> left, right)
|
||||
let _id = (fun value -> value), (fun value _ -> value)
|
||||
|
||||
let split = function
|
||||
| head :: tail -> head, tail
|
||||
| [] -> invalid_arg "Fieldglass: empty list"
|
||||
|
||||
let _hd =
|
||||
(fun source -> fst (split source)),
|
||||
(fun head source -> head :: snd (split source))
|
||||
|
||||
let _tl =
|
||||
(fun source -> snd (split source)),
|
||||
(fun tail source -> fst (split source) :: tail)
|
||||
Reference in new issue
Block a user