package catala
Install
Dune Dependency
Authors
Maintainers
Sources
md5=8f891209d18b6540df9c34b2d1a6a783
sha512=737770b87a057674bceefe77e8526720732552f51f424afcebcb6a628267eab522c4fd993caca1ae8ed7ace65a4a87e485af10c1676e51ca5939509a1b841ac2
doc/catala.shared_ast/Shared_ast/Scope/index.html
Module Shared_ast.Scope
Source
Functions handling the code item structures of shared_ast
, in particular the scopes
Traversal functions
val fold_left_lets :
f:('a -> 'e Shared_ast__.Definitions.scope_let -> 'e Var.t -> 'a) ->
init:'a ->
'e Shared_ast__.Definitions.scope_body_expr ->
'a
Usage: fold_left_lets ~f:(fun acc scope_let scope_let_var -> ...) ~init scope_lets
, where scope_let_var
is the variable bound to the scope let in the next scope lets to be examined.
val fold_right_lets :
f:('expr1 Shared_ast__.Definitions.scope_let -> 'expr1 Var.t -> 'a -> 'a) ->
init:('expr1 -> 'a) ->
'expr1 Shared_ast__.Definitions.scope_body_expr ->
'a
Usage: fold_right_lets ~f:(fun scope_let scope_let_var acc -> ...) ~init scope_lets
, where scope_let_var
is the variable bound to the scope let in the next scope lets to be examined (which are before in the program order).
val map_exprs_in_lets :
?reset_types:bool ->
f:('expr1 -> 'expr2 Shared_ast__.Definitions.boxed) ->
varf:('expr1 Var.t -> 'expr2 Var.t) ->
'expr1 Shared_ast__.Definitions.scope_body_expr ->
'expr2 Shared_ast__.Definitions.scope_body_expr Bindlib.box
Usage 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 TAny
.
val fold_left :
f:('a -> 'expr1 Shared_ast__.Definitions.code_item -> 'expr1 Var.t -> 'a) ->
init:'a ->
'expr1 Shared_ast__.Definitions.code_item_list ->
'a
Usage: fold_left ~f:(fun acc code_def code_var -> ...) ~init code_def
, where code_var
is the variable bound to the code item in the next code items to be examined.
val fold_right :
f:('expr1 Shared_ast__.Definitions.code_item -> 'expr1 Var.t -> 'a -> 'a) ->
init:'a ->
'expr1 Shared_ast__.Definitions.code_item_list ->
'a
Usage: fold_right_scope ~f:(fun scope_def scope_var acc -> ...) ~init scope_def
, where scope_var
is the variable bound to the scope in the next scopes to be examined (which are before in the program order).
val map :
f:
('e1 Shared_ast__.Definitions.code_item ->
'e2 Shared_ast__.Definitions.code_item Bindlib.box) ->
varf:('e1 Var.t -> 'e2 Var.t) ->
'e1 Shared_ast__.Definitions.code_item_list ->
'e2 Shared_ast__.Definitions.code_item_list Bindlib.box
val map_ctx :
f:
('ctx ->
'e1 Shared_ast__.Definitions.code_item ->
'ctx * 'e2 Shared_ast__.Definitions.code_item Bindlib.box) ->
varf:('e1 Var.t -> 'e2 Var.t) ->
'ctx ->
'e1 Shared_ast__.Definitions.code_item_list ->
'e2 Shared_ast__.Definitions.code_item_list Bindlib.box
Similar to map
, but a context is passed left-to-right through the given function
val fold_map :
f:
('ctx ->
'e1 Var.t ->
'e1 Shared_ast__.Definitions.code_item ->
'ctx * 'e2 Shared_ast__.Definitions.code_item Bindlib.box) ->
varf:('e1 Var.t -> 'e2 Var.t) ->
'ctx ->
'e1 Shared_ast__.Definitions.code_item_list ->
'ctx * 'e2 Shared_ast__.Definitions.code_item_list Bindlib.box
val map_exprs :
f:('expr1 -> 'expr2 Shared_ast__.Definitions.boxed) ->
varf:('expr1 Var.t -> 'expr2 Var.t) ->
'expr1 Shared_ast__.Definitions.code_item_list ->
'expr2 Shared_ast__.Definitions.code_item_list Bindlib.box
This is the main map visitor for all the expressions inside all the scopes of the program.
val get_body_mark :
((_, _, '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
Conversions
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 ->
'm Shared_ast__.Definitions.mark ->
(('a, 'a, 'm) Shared_ast__.Definitions.base_gexpr Bindlib.box,
'm Shared_ast__.Definitions.mark)
Catala_utils.Mark.ed
Usage: to_expr ctx body scope_position
where scope_position
corresponds to the line of the scope declaration for instance.
val unfold :
Shared_ast__.Definitions.decl_ctx ->
((_, _, 'm) Shared_ast__.Definitions.base_gexpr,
'm Shared_ast__.Definitions.mark)
Catala_utils.Mark.ed as 'e
Shared_ast__.Definitions.code_item_list ->
'm Shared_ast__.Definitions.mark ->
'e scope_name_or_var ->
'e Shared_ast__.Definitions.boxed
val build_typ_from_sig :
Shared_ast__.Definitions.decl_ctx ->
Shared_ast__.Definitions.StructName.t ->
Shared_ast__.Definitions.StructName.t ->
Catala_utils.Pos.t ->
Shared_ast__.Definitions.naked_typ Catala_utils.Mark.pos
build_typ_from_sig ctx in_struct out_struct pos
builds the arrow type for the specified scope
val input_type :
Shared_ast__.Definitions.naked_typ Catala_utils.Mark.pos ->
Runtime_ocaml.Runtime.io_input Catala_utils.Mark.pos ->
Shared_ast__.Definitions.naked_typ Catala_utils.Mark.pos
Returns 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)