Expr.Box
This module contains helper functions for Bindlib, and wrappers to use boxed expressions.
We use the boxed_expr = naked_expr box marked
type throughout, rather than the more straightforward expr box = naked_expr marked box
, because the latter would force us to resolve the box every time we need to recover the annotation, which happens often. It's more efficient and convenient to add the annotation outside of the box, and delay its injection (using lift
) to when the parent term gets built.
val lift :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
Bindlib.box
Inject the annotation within the box, to use e.g. when a gexpr box
is required for building parent terms
val app0 :
( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr ->
'm Shared_ast__Definitions.mark ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
The app*
functions allow building boxed expressions using Bindlib.apply_box
and its variants, while correctly handling the expression annotations. Note that the function provided as argument should return a naked_gexpr
and the expression annotation ('t
) is provided as a separate argument.
val app1 :
( ( 'a, 'a, 'm1 ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm1 Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
( ( ( 'a, 'a, 'm1 ) Shared_ast__Definitions.base_gexpr,
'm1 Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
( 'a, 'a, 'm2 ) Shared_ast__Definitions.base_gexpr ) ->
'm2 Shared_ast__Definitions.mark ->
( ( 'a, 'a, 'm2 ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm2 Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val app2 :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
( ( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr ) ->
'm Shared_ast__Definitions.mark ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val app3 :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
( ( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr ) ->
'm Shared_ast__Definitions.mark ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val appn :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
list ->
( ( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
list ->
( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr ) ->
'm Shared_ast__Definitions.mark ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val app1n :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
list ->
( ( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
list ->
( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr ) ->
'm Shared_ast__Definitions.mark ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val app2n :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
list ->
( ( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
list ->
( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr ) ->
'm Shared_ast__Definitions.mark ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed