package catala

  1. Overview
  2. Docs
module StructMap : Map.S with type key = StructName.t
module EnumMap : Map.S with type key = EnumName.t

Abstract syntax tree for the default calculus

Abstract syntax tree

type typ_lit =
  1. | TBool
  2. | TUnit
  3. | TInt
  4. | TRat
  5. | TMoney
  6. | TDate
  7. | TDuration
type typ =
  1. | TLit of typ_lit
  2. | TTuple of typ Utils.Pos.marked list * StructName.t option
  3. | TEnum of typ Utils.Pos.marked list * EnumName.t
  4. | TArrow of typ Utils.Pos.marked * typ Utils.Pos.marked
  5. | TArray of typ Utils.Pos.marked
  6. | TAny
type date = Runtime.date
type duration = Runtime.duration
type lit =
  1. | LBool of bool
  2. | LEmptyError
  3. | LInt of Runtime.integer
  4. | LRat of Runtime.decimal
  5. | LMoney of Runtime.money
  6. | LUnit
  7. | LDate of date
  8. | LDuration of duration
type op_kind =
  1. | KInt
  2. | KRat
  3. | KMoney
  4. | KDate
  5. | KDuration
    (*

    All ops don't have a Kdate and KDuration

    *)
type ternop =
  1. | Fold
type binop =
  1. | And
  2. | Or
  3. | Add of op_kind
  4. | Sub of op_kind
  5. | Mult of op_kind
  6. | Div of op_kind
  7. | Lt of op_kind
  8. | Lte of op_kind
  9. | Gt of op_kind
  10. | Gte of op_kind
  11. | Eq
  12. | Neq
  13. | Map
  14. | Filter
type log_entry =
  1. | VarDef
  2. | BeginCall
  3. | EndCall
  4. | PosRecordIfTrueBool
type unop =
  1. | Not
  2. | Minus of op_kind
  3. | ErrorOnEmpty
  4. | Log of log_entry * Utils.Uid.MarkedString.info list
  5. | Length
  6. | IntToRat
  7. | GetDay
  8. | GetMonth
  9. | GetYear
type operator =
  1. | Ternop of ternop
  2. | Binop of binop
  3. | Unop of unop
type expr =
  1. | EVar of expr Bindlib.var Utils.Pos.marked
  2. | ETuple of expr Utils.Pos.marked list * StructName.t option
    (*

    The MarkedString.info is the former struct field name

    *)
  3. | ETupleAccess of expr Utils.Pos.marked * int * StructName.t option * typ Utils.Pos.marked list
    (*

    The MarkedString.info is the former struct field name

    *)
  4. | EInj of expr Utils.Pos.marked * int * EnumName.t * typ Utils.Pos.marked list
    (*

    The MarkedString.info is the former enum case name

    *)
  5. | EMatch of expr Utils.Pos.marked * expr Utils.Pos.marked list * EnumName.t
    (*

    The MarkedString.info is the former enum case name

    *)
  6. | EArray of expr Utils.Pos.marked list
  7. | ELit of lit
  8. | EAbs of Utils.Pos.t * (expr, expr Utils.Pos.marked) Bindlib.mbinder * typ Utils.Pos.marked list
  9. | EApp of expr Utils.Pos.marked * expr Utils.Pos.marked list
  10. | EAssert of expr Utils.Pos.marked
  11. | EOp of operator
  12. | EDefault of expr Utils.Pos.marked list * expr Utils.Pos.marked * expr Utils.Pos.marked
  13. | EIfThenElse of expr Utils.Pos.marked * expr Utils.Pos.marked * expr Utils.Pos.marked

The expressions use the Bindlib library, based on higher-order abstract syntax

type decl_ctx = {
  1. ctx_enums : enum_ctx;
  2. ctx_structs : struct_ctx;
}

Variable helpers

module Var : sig ... end
module VarMap : Map.S with type key = Var.t
type vars = expr Bindlib.mvar
type program = {
  1. decl_ctx : decl_ctx;
  2. scopes : (ScopeName.t * Var.t * expr Utils.Pos.marked) list;
}