package catala

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

Scope dependencies computations using OCamlgraph

Scope variables dependency graph

Graph declaration

Vertices: scope variables or subscopes.

The vertices of the scope dependency graph are either :

  • the variables of the scope ;
  • the subscopes of the scope.

Indeed, during interpretation, subscopes are executed atomically.

module Vertex : sig ... end
module Edge : Graph.Sig.ORDERED_TYPE_DFT with type t = Catala_utils.Pos.t

On the edges, the label is the position of the expression responsible for the use of the variable. In the graph, x -> y if x is used in the definition of y.

module ScopeDependencies : Graph.Sig.P with type V.t = Vertex.t and type E.label = Edge.t

Module of the graph, provided by OCamlGraph

Graph computations

Returns an ordering of the scope variables and subscope compatible with the dependencies of the computation

val correct_computation_ordering : ScopeDependencies.t -> Vertex.t list

Returns an ordering of the scope variables and subscope compatible with the dependencies of the computation

val check_for_cycle : Ast.scope -> ScopeDependencies.t -> unit

Outputs an error in case of cycles.

val build_scope_dependencies : Ast.scope -> ScopeDependencies.t

Builds the dependency graph of a particular scope

Exceptions dependency graph

module EdgeExceptions : Graph.Sig.ORDERED_TYPE_DFT with type t = Catala_utils.Pos.t list
module ExceptionVertex : sig ... end
module ExceptionsDependencies : Graph.Sig.P with type V.t = ExceptionVertex.t and type E.label = EdgeExceptions.t
val build_exceptions_graph : Ast.rule Shared_ast.RuleName.Map.t -> Ast.ScopeDef.t -> ExceptionsDependencies.t
val check_for_exception_cycle : Ast.rule Shared_ast.RuleName.Map.t -> ExceptionsDependencies.t -> unit
OCaml

Innovation. Community. Security.