package catala

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

Abstract syntax tree for the lambda calculus

Abstract syntax tree

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

type lit =
  1. | LBool of bool
  2. | LInt of Runtime.integer
  3. | LRat of Runtime.decimal
  4. | LMoney of Runtime.money
  5. | LUnit
  6. | LDate of Runtime.date
  7. | LDuration of Runtime.duration
type except =
  1. | ConflictError
  2. | EmptyError
  3. | NoValueProvided
  4. | Crash
type expr =
  1. | EVar of expr Bindlib.var Utils.Pos.marked
  2. | ETuple of expr Utils.Pos.marked list * Dcalc.Ast.StructName.t option
    (*

    The MarkedString.info is the former struct field name

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

    The MarkedString.info is the former struct field name

    *)
  4. | EInj of expr Utils.Pos.marked * int * Dcalc.Ast.EnumName.t * Dcalc.Ast.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 * Dcalc.Ast.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 * Dcalc.Ast.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 Dcalc.Ast.operator
  12. | EIfThenElse of expr Utils.Pos.marked * expr Utils.Pos.marked * expr Utils.Pos.marked
  13. | ERaise of except
  14. | ECatch of expr Utils.Pos.marked * except * expr Utils.Pos.marked

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 -> Dcalc.Ast.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 -> Dcalc.Ast.typ Utils.Pos.marked -> expr Utils.Pos.marked Bindlib.box -> expr Utils.Pos.marked Bindlib.box -> expr Utils.Pos.marked Bindlib.box
val option_enum : Dcalc.Ast.EnumName.t
val none_constr : Dcalc.Ast.EnumConstructor.t
val some_constr : Dcalc.Ast.EnumConstructor.t
val make_none : Utils.Pos.t -> expr Utils.Pos.marked Bindlib.box
val make_some : expr Utils.Pos.marked Bindlib.box -> expr Utils.Pos.marked Bindlib.box
val make_matchopt_with_abs_arms : expr Utils.Pos.marked Bindlib.box -> expr Utils.Pos.marked Bindlib.box -> expr Utils.Pos.marked Bindlib.box -> expr Utils.Pos.marked Bindlib.box
val make_matchopt : Utils.Pos.t -> Var.t -> Dcalc.Ast.typ Utils.Pos.marked -> expr Utils.Pos.marked Bindlib.box -> expr Utils.Pos.marked Bindlib.box -> expr Utils.Pos.marked Bindlib.box -> expr Utils.Pos.marked Bindlib.box

e' = make_matchopt'' pos v e e_none e_some Builds the term corresponding to match e with | None -> fun () -> e_none |Some -> fun v -> e_some.

val handle_default : Var.t
val handle_default_opt : Var.t
type binder = (expr, expr Utils.Pos.marked) Bindlib.binder
type scope_body = {
  1. scope_body_name : Dcalc.Ast.ScopeName.t;
  2. scope_body_var : Var.t;
  3. scope_body_expr : expr Utils.Pos.marked;
}
type program = {
  1. decl_ctx : Dcalc.Ast.decl_ctx;
  2. scopes : scope_body list;
}
OCaml

Innovation. Community. Security.