package catala

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
module Runtime = Runtime_ocaml.Runtime

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 'm mark = 'm Dcalc.Ast.mark
type 'm marked_expr = ('m expr, 'm) Dcalc.Ast.marked
and 'm expr =
  1. | EVar of 'm expr Bindlib.var
  2. | ETuple of 'm marked_expr list * Dcalc.Ast.StructName.t option
    (*

    The MarkedString.info is the former struct field name

    *)
  3. | ETupleAccess of 'm marked_expr * int * Dcalc.Ast.StructName.t option * Dcalc.Ast.typ Utils.Marked.pos list
    (*

    The MarkedString.info is the former struct field name

    *)
  4. | EInj of 'm marked_expr * int * Dcalc.Ast.EnumName.t * Dcalc.Ast.typ Utils.Marked.pos list
    (*

    The MarkedString.info is the former enum case name

    *)
  5. | EMatch of 'm marked_expr * 'm marked_expr list * Dcalc.Ast.EnumName.t
    (*

    The MarkedString.info is the former enum case name

    *)
  6. | EArray of 'm marked_expr list
  7. | ELit of lit
  8. | EAbs of ('m expr, 'm marked_expr) Bindlib.mbinder * Dcalc.Ast.typ Utils.Marked.pos list
  9. | EApp of 'm marked_expr * 'm marked_expr list
  10. | EAssert of 'm marked_expr
  11. | EOp of Dcalc.Ast.operator
  12. | EIfThenElse of 'm marked_expr * 'm marked_expr * 'm marked_expr
  13. | ERaise of except
  14. | ECatch of 'm marked_expr * except * 'm marked_expr
type 'm program = ('m expr, 'm) Dcalc.Ast.program_generic

Variable helpers

type 'm var = 'm expr Bindlib.var
type 'm vars = 'm expr Bindlib.mvar
module Var : sig ... end
module VarMap : Stdlib.Map.S with type key = Var.t
module VarSet : Stdlib.Set.S with type elt = Var.t
val new_var : string -> 'm var
type 'm binder = ('m expr, 'm marked_expr) Bindlib.binder

Program traversal

val map_expr : 'a -> f:('a -> 'm1 marked_expr -> 'm2 marked_expr Bindlib.box) -> ('m1 expr, 'm2 mark) Utils.Marked.t -> 'm2 marked_expr Bindlib.box

See Dcalc.Ast.map_expr

val map_expr_top_down : f:('m1 marked_expr -> ('m1 expr, 'm2 mark) Utils.Marked.t) -> 'm1 marked_expr -> 'm2 marked_expr Bindlib.box

See Dcalc.Ast.map_expr_top_down

val map_expr_marks : f:('m1 mark -> 'm2 mark) -> 'm1 marked_expr -> 'm2 marked_expr Bindlib.box

See Dcalc.Ast.map_expr_marks

val untype_expr : 'm marked_expr -> Dcalc.Ast.untyped marked_expr Bindlib.box
val untype_program : 'm program -> Dcalc.Ast.untyped program

Boxed constructors

val evar : 'm expr Bindlib.var -> 'm mark -> 'm marked_expr Bindlib.box
val etuple : 'm marked_expr Bindlib.box list -> Dcalc.Ast.StructName.t option -> 'm mark -> 'm marked_expr Bindlib.box
val etupleaccess : 'm marked_expr Bindlib.box -> int -> Dcalc.Ast.StructName.t option -> Dcalc.Ast.typ Utils.Marked.pos list -> 'm mark -> 'm marked_expr Bindlib.box
val einj : 'm marked_expr Bindlib.box -> int -> Dcalc.Ast.EnumName.t -> Dcalc.Ast.typ Utils.Marked.pos list -> 'm mark -> 'm marked_expr Bindlib.box
val ematch : 'm marked_expr Bindlib.box -> 'm marked_expr Bindlib.box list -> Dcalc.Ast.EnumName.t -> 'm mark -> 'm marked_expr Bindlib.box
val earray : 'm marked_expr Bindlib.box list -> 'm mark -> 'm marked_expr Bindlib.box
val elit : lit -> 'm mark -> 'm marked_expr Bindlib.box
val eabs : ('m expr, 'm marked_expr) Bindlib.mbinder Bindlib.box -> Dcalc.Ast.typ Utils.Marked.pos list -> 'm mark -> 'm marked_expr Bindlib.box
val eapp : 'm marked_expr Bindlib.box -> 'm marked_expr Bindlib.box list -> 'm mark -> 'm marked_expr Bindlib.box
val eassert : 'm marked_expr Bindlib.box -> 'm mark -> 'm marked_expr Bindlib.box
val eop : Dcalc.Ast.operator -> 'm mark -> 'm marked_expr Bindlib.box
val eifthenelse : 'm marked_expr Bindlib.box -> 'm marked_expr Bindlib.box -> 'm marked_expr Bindlib.box -> 'm mark -> 'm marked_expr Bindlib.box
val ecatch : 'm marked_expr Bindlib.box -> except -> 'm marked_expr Bindlib.box -> 'm mark -> 'm marked_expr Bindlib.box
val eraise : except -> 'm mark -> 'm marked_expr Bindlib.box

Language terms construction

val make_var : ('m var, 'm) Dcalc.Ast.marked -> 'm marked_expr Bindlib.box
val make_abs : 'm vars -> 'm marked_expr Bindlib.box -> Dcalc.Ast.typ Utils.Marked.pos list -> 'm mark -> 'm marked_expr Bindlib.box
val make_app : 'm marked_expr Bindlib.box -> 'm marked_expr Bindlib.box list -> 'm mark -> 'm marked_expr Bindlib.box
val make_let_in : 'm var -> Dcalc.Ast.typ Utils.Marked.pos -> 'm marked_expr Bindlib.box -> 'm marked_expr Bindlib.box -> Utils.Pos.t -> 'm marked_expr Bindlib.box
val make_multiple_let_in : 'm vars -> Dcalc.Ast.typ Utils.Marked.pos list -> 'm marked_expr Bindlib.box list -> 'm marked_expr Bindlib.box -> Utils.Pos.t -> 'm marked_expr 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 : 'm mark -> 'm marked_expr Bindlib.box
val make_some : 'm marked_expr Bindlib.box -> 'm marked_expr Bindlib.box
val make_matchopt_with_abs_arms : 'm marked_expr Bindlib.box -> 'm marked_expr Bindlib.box -> 'm marked_expr Bindlib.box -> 'm marked_expr Bindlib.box
val make_matchopt : 'm mark -> 'm var -> Dcalc.Ast.typ Utils.Marked.pos -> 'm marked_expr Bindlib.box -> 'm marked_expr Bindlib.box -> 'm marked_expr Bindlib.box -> 'm marked_expr 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 box_expr : 'm marked_expr -> 'm marked_expr Bindlib.box

Special symbols

val handle_default : Var.t
val handle_default_opt : Var.t
OCaml

Innovation. Community. Security.