Shared_ast.BoundListBound lists are non-empty linked lists where each element is a binder onto the next. They are useful for ordered program definitions, like nested let-ins.
let a = e1 in e2 is thus represented as Cons (e1, {a. Last e2}).
The following provides a few utility functions for their traversal and manipulation. In particular, map functions take care of unbinding, then properly rebinding the variables.
type ('e, 'elt, 'last) t = | Last of 'last| Cons of 'elt * ('e, ('e, 'elt, 'last) t) Shared_ast__.Definitions.binderval to_seq :
(((_, _, _) Shared_ast__.Definitions.base_gexpr,
_ Shared_ast__.Definitions.mark)
Catala_utils.Mark.ed as 'e,
'elt,
_)
t ->
('e Var.t * 'elt) Stdlib.Seq.tNote that the boundlist terminator is ignored in the resulting sequence
val last : (_, _, 'a) t -> 'aval find : f:('elt -> 'a option) -> (_, 'elt, _) t -> 'aval fold_lr :
top:'dacc ->
down:('e Var.t -> 'elt -> 'dacc -> 'dacc) ->
bottom:('last -> 'dacc -> 'uacc) ->
up:('e Var.t -> 'elt -> 'uacc -> 'uacc) ->
('e, 'elt, 'last) t ->
'uaccBi-directional fold: down accumulates downwards, starting from top; upon reaching last, bottom is called; then up accumulates on the way back up
val map_last :
f:('e1 Var.t -> 'elt1 -> 'e2 Var.t * 'elt2 Bindlib.box) ->
last:('last1 -> ('e2, 'elt2, 'last2) t Bindlib.box) ->
('e1, 'elt1, 'last1) t ->
('e2, 'elt2, 'last2) t Bindlib.boxA more expressive version of map that allows extending the tail (e.g. to append new elements)
val equal :
f:('elt -> 'elt -> bool) ->
last:('last -> 'last -> bool) ->
(('e, 'elt, 'last) t as 'l) ->
'l ->
boolval compare :
f:('elt -> 'elt -> int) ->
last:('last -> 'last -> int) ->
(('e, 'elt, 'last) t as 'l) ->
'l ->
int