package catala

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
module StructMap : Stdlib.Map.S with type key = StructName.t
module EnumMap : Stdlib.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. | Xor
  4. | Add of op_kind
  5. | Sub of op_kind
  6. | Mult of op_kind
  7. | Div of op_kind
  8. | Lt of op_kind
  9. | Lte of op_kind
  10. | Gt of op_kind
  11. | Gte of op_kind
  12. | Eq
  13. | Neq
  14. | Map
  15. | Concat
  16. | Filter
type log_entry =
  1. | VarDef of typ
    (*

    During code generation, we need to know the type of the variable being logged for embedding

    *)
  2. | BeginCall
  3. | EndCall
  4. | PosRecordIfTrueBool
type unop =
  1. | Not
  2. | Minus of op_kind
  3. | Log of log_entry * Utils.Uid.MarkedString.info list
  4. | Length
  5. | IntToRat
  6. | GetDay
  7. | GetMonth
  8. | 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 (expr, expr Utils.Pos.marked) Bindlib.mbinder Utils.Pos.marked * 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
  14. | ErrorOnEmpty of expr Utils.Pos.marked

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

type struct_ctx = (StructFieldName.t * typ Utils.Pos.marked) list StructMap.t
type enum_ctx = (EnumConstructor.t * typ Utils.Pos.marked) list EnumMap.t
type decl_ctx = {
  1. ctx_enums : enum_ctx;
  2. ctx_structs : struct_ctx;
}

Variable helpers

module Var : sig ... end
module VarMap : Stdlib.Map.S with type key = Var.t
type vars = expr Bindlib.mvar
val make_var : Var.t Utils.Pos.marked -> expr Utils.Pos.marked Bindlib.box
val make_abs : vars -> expr Utils.Pos.marked Bindlib.box -> Utils.Pos.t -> typ Utils.Pos.marked list -> Utils.Pos.t -> expr Utils.Pos.marked Bindlib.box
val make_app : expr Utils.Pos.marked Bindlib.box -> expr Utils.Pos.marked Bindlib.box list -> Utils.Pos.t -> expr Utils.Pos.marked Bindlib.box
val make_let_in : Var.t -> typ Utils.Pos.marked -> expr Utils.Pos.marked Bindlib.box -> expr Utils.Pos.marked Bindlib.box -> Utils.Pos.t -> expr Utils.Pos.marked Bindlib.box
val make_multiple_let_in : Var.t array -> typ Utils.Pos.marked list -> expr Utils.Pos.marked Bindlib.box list -> expr Utils.Pos.marked Bindlib.box -> Utils.Pos.t -> expr Utils.Pos.marked Bindlib.box
type binder = (expr, expr Utils.Pos.marked) Bindlib.binder
type program = {
  1. decl_ctx : decl_ctx;
  2. scopes : (ScopeName.t * Var.t * expr Utils.Pos.marked) list;
}
OCaml

Innovation. Community. Security.