Shared_ast.Expr
Functions handling the expressions of shared_ast
val box :
( ( '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 Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
Box the expression from the outside
val unbox :
( ( '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
For closed expressions, similar to Bindlib.unbox
val rebox :
( ( 'a Shared_ast__Definitions.any, 'a Shared_ast__Definitions.any, 'm )
Shared_ast__Definitions.base_gexpr,
'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
Rebuild the whole term, re-binding all variables and exposing free variables
val evar :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
Var.t ->
'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 bind :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
Var.t
array ->
( ( '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,
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed )
Bindlib.mbinder
Bindlib.box
val subst :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed )
Bindlib.mbinder ->
( ( '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 )
Catala_utils.Mark.ed
val etuple :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
list ->
'm Shared_ast__Definitions.mark ->
( ( 'a Shared_ast__Definitions.any, 'a Shared_ast__Definitions.any, 'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val etupleaccess :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
int ->
int ->
'm Shared_ast__Definitions.mark ->
( ( 'a Shared_ast__Definitions.any, 'a Shared_ast__Definitions.any, 'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val earray :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
list ->
'm Shared_ast__Definitions.mark ->
( ( 'a Shared_ast__Definitions.any, 'a Shared_ast__Definitions.any, 'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val elit :
Shared_ast__Definitions.lit ->
'm Shared_ast__Definitions.mark ->
( ( 'a Shared_ast__Definitions.any, 'a Shared_ast__Definitions.any, 'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val eabs :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed )
Bindlib.mbinder
Bindlib.box ->
Shared_ast__Definitions.naked_typ Catala_utils.Mark.pos list ->
'm Shared_ast__Definitions.mark ->
( ( 'a Shared_ast__Definitions.any, 'a Shared_ast__Definitions.any, 'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val eapp :
( ( '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 ->
'm Shared_ast__Definitions.mark ->
( ( 'a Shared_ast__Definitions.any, 'a Shared_ast__Definitions.any, 'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val eassert :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
'm Shared_ast__Definitions.mark ->
( ( < assertions : Shared_ast__Definitions.yes.. > as 'a,
< assertions : Shared_ast__Definitions.yes.. > as 'a,
'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val eop :
'a Shared_ast__Definitions.Op.t ->
Shared_ast__Definitions.naked_typ Catala_utils.Mark.pos list ->
'm Shared_ast__Definitions.mark ->
( ( 'a Shared_ast__Definitions.any, 'a Shared_ast__Definitions.any, 'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val edefault :
( ( '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 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 ->
'm Shared_ast__Definitions.mark ->
( ( < defaultTerms : Shared_ast__Definitions.yes.. > as 'a,
< defaultTerms : Shared_ast__Definitions.yes.. > as 'a,
'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val eifthenelse :
( ( '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 ->
'm Shared_ast__Definitions.mark ->
( ( 'a Shared_ast__Definitions.any, 'a Shared_ast__Definitions.any, 'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val eemptyerror :
'm Shared_ast__Definitions.mark ->
( ( < defaultTerms : Shared_ast__Definitions.yes.. > as 'a,
< defaultTerms : Shared_ast__Definitions.yes.. > as 'a,
'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val eerroronempty :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
'm Shared_ast__Definitions.mark ->
( ( < defaultTerms : Shared_ast__Definitions.yes.. > as 'a,
< defaultTerms : Shared_ast__Definitions.yes.. > as 'a,
'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val ecatch :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
Shared_ast__Definitions.except ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
'm Shared_ast__Definitions.mark ->
( ( < exceptions : Shared_ast__Definitions.yes.. > as 'a,
< exceptions : Shared_ast__Definitions.yes.. > as 'a,
'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val eraise :
Shared_ast__Definitions.except ->
'm Shared_ast__Definitions.mark ->
( ( < exceptions : Shared_ast__Definitions.yes.. >,
< exceptions : Shared_ast__Definitions.yes.. >,
'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val elocation :
'a Shared_ast__Definitions.glocation ->
'm Shared_ast__Definitions.mark ->
( ( < .. > as 'a, < .. > as 'a, 'm ) Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val estruct :
Shared_ast__Definitions.StructName.t ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
Shared_ast__Definitions.StructField.Map.t ->
'm Shared_ast__Definitions.mark ->
( ( 'a Shared_ast__Definitions.any, 'a Shared_ast__Definitions.any, 'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val edstructaccess :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
Catala_utils.String.t ->
Shared_ast__Definitions.StructName.t option ->
'm Shared_ast__Definitions.mark ->
( ( < syntacticNames : Shared_ast__Definitions.yes.. > as 'a,
< syntacticNames : Shared_ast__Definitions.yes.. > as 'a,
'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val estructaccess :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
Shared_ast__Definitions.StructField.t ->
Shared_ast__Definitions.StructName.t ->
'm Shared_ast__Definitions.mark ->
( ( < resolvedNames : Shared_ast__Definitions.yes.. > as 'a,
< resolvedNames : Shared_ast__Definitions.yes.. > as 'a,
'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val einj :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
Shared_ast__Definitions.EnumConstructor.t ->
Shared_ast__Definitions.EnumName.t ->
'm Shared_ast__Definitions.mark ->
( ( 'a Shared_ast__Definitions.any, 'a Shared_ast__Definitions.any, 'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val ematch :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
Shared_ast__Definitions.EnumName.t ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
Shared_ast__Definitions.EnumConstructor.Map.t ->
'm Shared_ast__Definitions.mark ->
( ( 'a Shared_ast__Definitions.any, 'a Shared_ast__Definitions.any, 'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val escopecall :
Shared_ast__Definitions.ScopeName.t ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
Shared_ast__Definitions.ScopeVar.Map.t ->
'm Shared_ast__Definitions.mark ->
( ( < explicitScopes : Shared_ast__Definitions.yes.. > as 'a,
< explicitScopes : Shared_ast__Definitions.yes.. > as 'a,
'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val fun_id :
'm Shared_ast__Definitions.mark ->
( ( 'a Shared_ast__Definitions.any, 'a Shared_ast__Definitions.any, 'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
Returns an empty mark, using the argument as type witness. Note that the custom part is kept on Custom
marks
val mark_pos : 'm Shared_ast__Definitions.mark -> Catala_utils.Pos.t
val with_pos :
Catala_utils.Pos.t ->
'm Shared_ast__Definitions.mark ->
'm Shared_ast__Definitions.mark
val with_ty :
'm Shared_ast__Definitions.mark ->
?pos:Catala_utils.Pos.t ->
Shared_ast__Definitions.naked_typ Catala_utils.Mark.pos ->
'm Shared_ast__Definitions.mark
Adds the given type information only on typed marks
val map_ty :
( Shared_ast__Definitions.naked_typ Catala_utils.Mark.pos ->
Shared_ast__Definitions.naked_typ Catala_utils.Mark.pos ) ->
'm Shared_ast__Definitions.mark ->
'm Shared_ast__Definitions.mark
Identity on untyped marks
val map_mark :
( Catala_utils.Pos.t -> Catala_utils.Pos.t ) ->
( Shared_ast__Definitions.naked_typ Catala_utils.Mark.pos ->
Shared_ast__Definitions.naked_typ Catala_utils.Mark.pos ) ->
'm Shared_ast__Definitions.mark ->
'm Shared_ast__Definitions.mark
val map_mark2 :
( Catala_utils.Pos.t -> Catala_utils.Pos.t -> Catala_utils.Pos.t ) ->
( Shared_ast__Definitions.typed ->
Shared_ast__Definitions.typed ->
Shared_ast__Definitions.naked_typ Catala_utils.Mark.pos ) ->
'm Shared_ast__Definitions.mark ->
'm Shared_ast__Definitions.mark ->
'm Shared_ast__Definitions.mark
val fold_marks :
( Catala_utils.Pos.t list -> Catala_utils.Pos.t ) ->
( Shared_ast__Definitions.typed list ->
Shared_ast__Definitions.naked_typ Catala_utils.Mark.pos ) ->
'm Shared_ast__Definitions.mark list ->
'm Shared_ast__Definitions.mark
val maybe_ty :
?typ:Shared_ast__Definitions.naked_typ ->
'm Shared_ast__Definitions.mark ->
Shared_ast__Definitions.naked_typ Catala_utils.Mark.pos
Returns the corresponding type on a typed expr, or typ
(defaulting to TAny
) at the current position on an untyped one
val option_enum_config :
Shared_ast__Definitions.naked_typ Catala_utils.Mark.pos
Shared_ast__Definitions.EnumConstructor.Map.t
Manipulation of marked expressions
val pos :
( 'a, 'm Shared_ast__Definitions.mark ) Catala_utils.Mark.ed ->
Catala_utils.Pos.t
val ty :
( 'e, Shared_ast__Definitions.typed Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
Shared_ast__Definitions.naked_typ Catala_utils.Mark.pos
val set_ty :
Shared_ast__Definitions.naked_typ Catala_utils.Mark.pos ->
( 'a, 'm Shared_ast__Definitions.mark ) Catala_utils.Mark.ed ->
( 'a, Shared_ast__Definitions.typed Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val untype :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
( ( 'a, 'a, Shared_ast__Definitions.untyped )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
Shared_ast__Definitions.untyped Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val map :
f:
( ( ( 'a, 'a, 'm1 ) Shared_ast__Definitions.base_gexpr,
'm1 Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
( ( 'b, 'b, 'm2 ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm2 Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ) ->
( ( 'a, 'b, 'm1 ) Shared_ast__Definitions.base_gexpr,
'm2 Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
( ( 'b, 'b, 'm2 ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm2 Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
Shallow mapping on expressions (non recursive): applies the given function to all sub-terms of the given expression, and rebuilds the node.
This function makes it very concise to transform only certain nodes of the AST. For instance, if you want to remove all errors on empty, you can write
let remove_error_empty e =
let rec f e =
match Mark.remove e with
| EErrorOnEmpty e1 -> Expr.map ~f e1
| _ -> Expr.map ~f e
in
f e
This can even be used to translate between different kinds of ASTs: see Lcalc.Compile_without_exceptions
for an example. The structure is like this:
let rec translate = function
| SpecificCase e -> TargetCase (translate e)
| (All | Other | Common | Cases) as e -> Expr.map ~f:translate e
The e
parameter passed to map
here needs to have only the common cases in its shallow type, but can still contain any node from the starting AST deeper inside: this is where the second type parameter to base_gexpr
becomes useful.
val map_top_down :
f:
( ( ( 'a, 'a, 'm1 ) Shared_ast__Definitions.base_gexpr,
'm1 Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
( ( 'a, 'a, 'm1 ) Shared_ast__Definitions.base_gexpr,
'm2 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 Bindlib.box,
'm2 Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
Recursively applies f
to the nodes of the expression tree. The type returned by f
is hybrid since the mark at top-level has been rewritten, but not yet the marks in the subtrees.
val map_marks :
f:( 'm1 Shared_ast__Definitions.mark -> 'm2 Shared_ast__Definitions.mark ) ->
( ( '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 Bindlib.box,
'm2 Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val shallow_fold :
( ( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
'acc ->
'acc ) ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
'acc ->
'acc
Applies a function on all sub-terms of the given expression. Does not recurse. It opens binders unless you avoid sending binders to the function like the example below. Useful as helper for recursive calls within traversal functions. This can be used to compute free variables with e.g.:
let rec free_vars = function
| EVar v, _ -> Var.Set.singleton v
| EAbs { binder; _ }, _ ->
let vs, body = Bindlib.unmbind binder in
Array.fold_right Var.Set.remove vs (free_vars body)
| e ->
shallow_fold (fun e -> Var.Set.union (free_vars e)) e Var.Set.empty
val map_gather :
acc:'acc ->
join:( 'acc -> 'acc -> 'acc ) ->
f:
( ( ( 'a, 'a, 'm1 ) Shared_ast__Definitions.base_gexpr,
'm1 Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
'acc
* ( ( 'a, 'a, 'm2 ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm2 Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ) ->
( ( 'a, 'a, 'm1 ) Shared_ast__Definitions.base_gexpr,
'm2 Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
'acc
* ( ( 'a, 'a, 'm2 ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm2 Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
Shallow mapping similar to map
, but additionally allows to gather an accumulator bottom-up. acc
is the accumulator value returned on terminal nodes, and join
is used to merge accumulators from the different sub-terms of an expression. acc
is assumed to be a neutral element for join
. Typically used with a set of variables used in the rewrite:
let rec rewrite e =
match Mark.remove e with
| Specific_case -> Var.Set.singleton x, some_rewrite_fun e
| _ ->
Expr.map_gather ~acc:Var.Set.empty ~join:Var.Set.union ~f:rewrite e
See Lcalc.closure_conversion
for a real-world example.
val make_var :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
Var.t ->
'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 make_abs :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
Var.vars ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
Shared_ast__Definitions.naked_typ Catala_utils.Mark.pos list ->
Catala_utils.Pos.t ->
( ( 'a Shared_ast__Definitions.any, 'a Shared_ast__Definitions.any, 'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val make_app :
( ( 'a Shared_ast__Definitions.any, 'a Shared_ast__Definitions.any, '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 ->
Catala_utils.Pos.t ->
( ( 'a Shared_ast__Definitions.any, 'a Shared_ast__Definitions.any, 'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val empty_thunked_term :
'm Shared_ast__Definitions.mark ->
( ( < defaultTerms : Shared_ast__Definitions.yes.. >,
< defaultTerms : Shared_ast__Definitions.yes.. >,
'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val thunk_term :
( ( 'a Shared_ast__Definitions.any, 'a Shared_ast__Definitions.any, 'b )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'b Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
'b Shared_ast__Definitions.mark ->
( ( 'a, 'a, 'b ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'b Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val unthunk_term_nobox :
( ( 'a Shared_ast__Definitions.any, 'a Shared_ast__Definitions.any, 'm )
Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
'm Shared_ast__Definitions.mark ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val make_let_in :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
Var.t ->
Shared_ast__Definitions.naked_typ Catala_utils.Mark.pos ->
( ( '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 ->
Catala_utils.Pos.t ->
( ( 'a Shared_ast__Definitions.any, 'a Shared_ast__Definitions.any, 'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val make_multiple_let_in :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
Var.vars ->
Shared_ast__Definitions.naked_typ Catala_utils.Mark.pos list ->
( ( '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 Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
Catala_utils.Pos.t ->
( ( 'a Shared_ast__Definitions.any, 'a Shared_ast__Definitions.any, 'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
val make_default :
( ( '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 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 ->
'm Shared_ast__Definitions.mark ->
( ( < polymorphic : Shared_ast__Definitions.yes
; defaultTerms : Shared_ast__Definitions.yes.. > as 'a,
< polymorphic : Shared_ast__Definitions.yes
; defaultTerms : Shared_ast__Definitions.yes.. > as 'a,
'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
make_default ?pos exceptions just cons
builds a term semantically equivalent to <exceptions | just :- cons>
(the EDefault
constructor) while avoiding redundant nested constructions. The position is extracted from just
by default.
Note that some simplifications take place here, even though all of them return an EDefault
term:
<ex | true :- def>
, when def
is a default term <j :- c>
without exceptions, is collapsed into <ex | def>
<ex | false :- _>
, when ex
is a single exception of the form EDefault
, is rewritten as ex
val make_tuple :
( ( 'a Shared_ast__Definitions.any, 'a Shared_ast__Definitions.any, 'm )
Shared_ast__Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
list ->
'm Shared_ast__Definitions.mark ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr Bindlib.box,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed
Builds a tuple; the mark argument is only used as witness and for position when building 0-uples
val skip_wrappers :
( ( '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
Removes surface logging calls and EErrorOnEmpty
nodes. Shallow function
val remove_logging_calls :
( ( < polymorphic : Shared_ast__Definitions.yes.. > as 'a,
< polymorphic : Shared_ast__Definitions.yes.. > as 'a,
'm )
Shared_ast__Definitions.base_gexpr,
'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
Removes all calls to Log
unary operators in the AST, replacing them by their argument.
val format :
Stdlib.Format.formatter ->
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
unit
Simple printing without debug, use Print.expr ()
instead to follow the command-line debug setting
val equal_location :
'a Shared_ast__Definitions.glocation Catala_utils.Mark.pos ->
'a Shared_ast__Definitions.glocation Catala_utils.Mark.pos ->
bool
val compare_location :
'a Shared_ast__Definitions.glocation Catala_utils.Mark.pos ->
'a Shared_ast__Definitions.glocation Catala_utils.Mark.pos ->
int
val equal :
( ( '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 ->
bool
Determines if two expressions are equal, omitting their position information
val compare :
( ( '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 ->
int
Standard comparison function, suitable for e.g. Set.Make
. Ignores position information
val is_value :
( ( 'a Shared_ast__Definitions.any, 'a Shared_ast__Definitions.any, 'm )
Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
bool
val free_vars :
( ( 'a Shared_ast__Definitions.any, 'a Shared_ast__Definitions.any, '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
Var.Set.t
val size :
( ( 'a, 'a, 'm ) Shared_ast__Definitions.base_gexpr,
'm Shared_ast__Definitions.mark )
Catala_utils.Mark.ed ->
int
Used by the optimizer to know when to stop
module Box : sig ... end