package catala

  1. Overview
  2. Docs
module Pos = Utils.Pos
module Uid = Utils.Uid

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 Pos.marked list
  3. | TEnum of typ Pos.marked list
  4. | TArrow of typ Pos.marked * typ Pos.marked
type date = ODate.Unix.t
type duration = Z.t
type lit =
  1. | LBool of bool
  2. | LEmptyError
  3. | LInt of Z.t
  4. | LRat of Q.t
  5. | LMoney of Z.t
  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 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
type log_entry =
  1. | VarDef
  2. | BeginCall
  3. | EndCall
type unop =
  1. | Not
  2. | Minus of op_kind
  3. | ErrorOnEmpty
  4. | Log of log_entry * Utils.Uid.MarkedString.info list
type operator =
  1. | Binop of binop
  2. | Unop of unop
type expr =
  1. | EVar of expr Bindlib.var Pos.marked
  2. | ETuple of (expr Pos.marked * Uid.MarkedString.info option) list
    (*

    The MarkedString.info is the former struct field name

    *)
  3. | ETupleAccess of expr Pos.marked * int * Uid.MarkedString.info option
    (*

    The MarkedString.info is the former struct field name

    *)
  4. | EInj of expr Pos.marked * int * Uid.MarkedString.info * typ Pos.marked list
    (*

    The MarkedString.info is the former enum case name

    *)
  5. | EMatch of expr Pos.marked * (expr Pos.marked * Uid.MarkedString.info) list
    (*

    The MarkedString.info is the former enum case name

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

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

Variable helpers

module Var : sig ... end
module VarMap : sig ... end
type vars = expr Bindlib.mvar
val make_var : Var.t Pos.marked -> expr Pos.marked Bindlib.box
val make_abs : vars -> expr Pos.marked Bindlib.box -> Pos.t -> typ Pos.marked list -> Pos.t -> expr Pos.marked Bindlib.box
val make_app : expr Pos.marked Bindlib.box -> expr Pos.marked Bindlib.box list -> Pos.t -> expr Pos.marked Bindlib.box
val make_let_in : Var.t -> typ Pos.marked -> expr Pos.marked Bindlib.box -> expr Pos.marked Bindlib.box -> expr Pos.marked Bindlib.box
type binder = (expr, expr Pos.marked) Bindlib.binder
OCaml

Innovation. Community. Security.