package catala
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=2615968670ac21b1d00386a9b04b3843
sha512=eff292fdd75012f26ce7b17020f5a8374eef37cd4dd6ba60338dfbe89fbcad3443d1b409e44c182b740da9f58dff7e76dcb8ddefe47f9b2b160666d1c6930143
doc/catala.shared_ast/Shared_ast/Scope/index.html
Module Shared_ast.ScopeSource
Functions handling the code item structures of shared_ast, in particular the scopes
Traversal functions
val map_exprs_in_lets :
?typ:
(Shared_ast__.Definitions.naked_typ Catala_utils.Mark.pos ->
Shared_ast__.Definitions.naked_typ Catala_utils.Mark.pos) ->
f:('expr1 -> 'expr2 Shared_ast__.Definitions.boxed) ->
varf:('expr1 Var.t -> 'expr2 Var.t) ->
('expr1, 'expr1 Shared_ast__.Definitions.scope_let, 'expr1)
Shared_ast__.Definitions.bound_list ->
('expr2, 'expr2 Shared_ast__.Definitions.scope_let, 'expr2)
Shared_ast__.Definitions.bound_list
Bindlib.boxUsage map_exprs_in_lets ~f:(fun e -> ...) ~varf:(fun var -> ...) scope_body_expr, where e is the right-hand-side of a scope let or the result of the scope body, and var represents the left-hand-side variable of a scope let. ~varf is usually the identity function or Var.translate when the map sends the expression to a new flavor of the shared AST. If ~reset_types is activated, then the resulting types in the scope let left-hand-sides will be reset to TForAll.
val map_exprs :
?typ:
(Shared_ast__.Definitions.naked_typ Catala_utils.Mark.pos ->
Shared_ast__.Definitions.naked_typ Catala_utils.Mark.pos) ->
f:('expr1 -> 'expr2 Shared_ast__.Definitions.boxed) ->
varf:('expr1 Var.t -> 'expr2 Var.t) ->
('expr1,
'expr1 Shared_ast__.Definitions.code_item,
(Shared_ast__.Definitions.code_export_kind * 'expr1) list)
Shared_ast__.Definitions.bound_list ->
('expr2,
'expr2 Shared_ast__.Definitions.code_item,
(Shared_ast__.Definitions.code_export_kind * 'expr2) list)
Shared_ast__.Definitions.bound_list
Bindlib.boxThis is the main map visitor for all the expressions inside all the scopes of the program.
val map_exports :
((('a1, 'a1, 'm1) Shared_ast__.Definitions.base_gexpr,
'm1 Shared_ast__.Definitions.mark)
Catala_utils.Mark.ed ->
(('a2, 'a2, 'm2) Shared_ast__.Definitions.base_gexpr,
'm2 Shared_ast__.Definitions.mark)
Catala_utils.Mark.ed
Shared_ast__.Definitions.boxed) ->
(Shared_ast__.Definitions.code_export_kind
* (('a1, 'a1, 'm1) Shared_ast__.Definitions.base_gexpr,
'm1 Shared_ast__.Definitions.mark)
Catala_utils.Mark.ed)
list ->
(Shared_ast__.Definitions.code_export_kind
* (('a2, 'a2, 'm2) Shared_ast__.Definitions.base_gexpr,
'm2 Shared_ast__.Definitions.mark)
Catala_utils.Mark.ed)
list
Bindlib.boxHelper function to handle the code_export list terminator when manually mapping on code_item_list
val fold_exprs :
f:
('acc ->
'expr ->
Shared_ast__.Definitions.naked_typ Catala_utils.Mark.pos ->
'acc) ->
init:'acc ->
('expr,
'expr Shared_ast__.Definitions.code_item,
(Shared_ast__.Definitions.code_export_kind * 'expr) list)
Shared_ast__.Definitions.bound_list ->
'accConversions
val to_expr :
Shared_ast__.Definitions.decl_ctx ->
(('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
Shared_ast__.Definitions.scope_body ->
(('a, 'a, 'm) Shared_ast__.Definitions.base_gexpr Bindlib.box,
'm Shared_ast__.Definitions.mark)
Catala_utils.Mark.edUsage: to_expr ctx body scope_position where scope_position corresponds to the line of the scope declaration for instance.
val unfold_body_expr :
Shared_ast__.Definitions.decl_ctx ->
('e, 'e Shared_ast__.Definitions.scope_let, 'e)
Shared_ast__.Definitions.bound_list ->
'e Shared_ast__.Definitions.boxedval unfold :
Shared_ast__.Definitions.decl_ctx ->
('e,
'e Shared_ast__.Definitions.code_item,
(Shared_ast__.Definitions.code_export_kind * 'e) list)
Shared_ast__.Definitions.bound_list ->
Shared_ast__.Definitions.ScopeName.t ->
'e Shared_ast__.Definitions.boxedval typ :
_ Shared_ast__.Definitions.scope_body ->
Shared_ast__.Definitions.naked_typ Catala_utils.Mark.posbuilds the arrow type for the specified scope
val input_type :
Shared_ast__.Definitions.naked_typ Catala_utils.Mark.pos ->
Catala_runtime.io_input Catala_utils.Mark.pos ->
Shared_ast__.Definitions.naked_typ Catala_utils.Mark.posReturns the correct input type for scope input variables: this is typ for non-reentrant variables, but for reentrant variables, it is nested in a TDefault, which only applies to the return type on functions. Note that this doesn't take thunking into account (thunking is added during the scopelang->dcalc translation)
val empty_input_struct_dcalc :
Shared_ast__.Definitions.decl_ctx ->
Shared_ast__.Definitions.StructName.t ->
'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.edSee empty_input_struct_lcalc.
val empty_input_struct_lcalc :
Shared_ast__.Definitions.decl_ctx ->
Shared_ast__.Definitions.StructName.t ->
'm Shared_ast__.Definitions.mark ->
((< polymorphic : Shared_ast__.Definitions.yes.. >,
< polymorphic : Shared_ast__.Definitions.yes.. >,
'm)
Shared_ast__.Definitions.base_gexpr
Bindlib.box,
'm Shared_ast__.Definitions.mark)
Catala_utils.Mark.edAssuming the given scope doesn't require any input, generate the minimal argument to call it. The scope may have context variables, that will be passed as None. The type will be initialised in the given mark: it is only used for position and as witness
Analysis and tests
val get_mark_witness :
((_, _, 'm) Shared_ast__.Definitions.base_gexpr,
'm Shared_ast__.Definitions.mark)
Catala_utils.Mark.ed
Shared_ast__.Definitions.scope_body ->
'm Shared_ast__.Definitions.mark option