package catala

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Abstract syntax tree of the desugared representation

module ScopeDef : sig ... end

Inside a scope, a definition can refer to a variable (possibly an intermediate state thereof) or an input of a subscope.

AST

Expressions

module LocationSet : Stdlib.Set.S with type elt = location Catala_utils.Mark.pos
module ExprMap : Catala_utils.Map.S with type key = expr

Rules and scopes

type exception_situation =
  1. | BaseCase
  2. | ExceptionToLabel of Shared_ast.LabelName.t Catala_utils.Mark.pos
  3. | ExceptionToRule of Shared_ast.RuleName.t Catala_utils.Mark.pos
type label_situation =
  1. | ExplicitlyLabeled of Shared_ast.LabelName.t Catala_utils.Mark.pos
  2. | Unlabeled
type rule = {
  1. rule_id : Shared_ast.RuleName.t;
  2. rule_just : expr Shared_ast.boxed;
  3. rule_cons : expr Shared_ast.boxed;
  4. rule_parameter : (expr Shared_ast.Var.t Catala_utils.Mark.pos * Shared_ast.typ) list Catala_utils.Mark.pos option;
  5. rule_exception : exception_situation;
  6. rule_label : label_situation;
}
module Rule : Stdlib.Set.OrderedType with type t = rule
type assertion = expr Shared_ast.boxed
type variation_typ =
  1. | Increasing
  2. | Decreasing
type reference_typ =
  1. | Decree
  2. | Law
type catala_option =
  1. | DateRounding of variation_typ
type meta_assertion =
  1. | FixedBy of reference_typ Catala_utils.Mark.pos
  2. | VariesWith of unit * variation_typ Catala_utils.Mark.pos option
type io = {
  1. io_output : bool Catala_utils.Mark.pos;
    (*

    true is present in the output of the scope.

    *)
  2. io_input : Shared_ast.Runtime.io_input Catala_utils.Mark.pos;
}

Characterization of the input/output status of a scope variable.

type scope_def = {
  1. scope_def_rules : rule Shared_ast.RuleName.Map.t;
    (*

    empty outside of the root module

    *)
  2. scope_def_typ : Shared_ast.typ;
  3. scope_def_parameters : (Catala_utils.Uid.MarkedString.info * Shared_ast.typ) list Catala_utils.Mark.pos option;
  4. scope_def_is_condition : bool;
  5. scope_def_io : io;
}
type var_or_states =
  1. | WholeVar
  2. | States of Shared_ast.StateName.t list
type scope = {
  1. scope_vars : var_or_states Shared_ast.ScopeVar.Map.t;
  2. scope_sub_scopes : Shared_ast.ScopeName.t Shared_ast.ScopeVar.Map.t;
  3. scope_uid : Shared_ast.ScopeName.t;
  4. scope_defs : scope_def ScopeDef.Map.t;
  5. scope_assertions : assertion AssertionName.Map.t;
    (*

    empty outside of the root module

    *)
  6. scope_options : catala_option Catala_utils.Mark.pos list;
  7. scope_meta_assertions : meta_assertion list;
}
type modul = {
  1. module_scopes : scope Shared_ast.ScopeName.Map.t;
  2. module_topdefs : (expr option * Shared_ast.typ) Shared_ast.TopdefName.Map.t;
    (*

    the expr is None outside of the root module

    *)
}
type program = {
  1. program_module_name : Shared_ast.Ident.t Catala_utils.Mark.pos option;
  2. program_ctx : Shared_ast.decl_ctx;
  3. program_modules : modul Shared_ast.ModuleName.Map.t;
    (*

    Contains all submodules of the program, in a flattened structure

    *)
  4. program_root : modul;
  5. program_lang : Catala_utils.Global.backend_lang;
}

Helpers

val locations_used : expr -> LocationSet.t
val fold_exprs : f:('a -> expr -> 'a) -> init:'a -> program -> 'a

Usage: fold_exprs ~f ~init program applies ~f to all the expressions inside rules (justifications and consequences), expressions and top-level definitions of the program. Note that there may be free variables in these expressions.

OCaml

Innovation. Community. Security.