package catala

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

Types

type money
type integer
type decimal
type date
type duration
type source_position = {
  1. filename : string;
  2. start_line : int;
  3. start_column : int;
  4. end_line : int;
  5. end_column : int;
  6. law_headings : string list;
}

Exceptions

exception EmptyError
exception AssertionFailed
exception ConflictError
exception UncomparableDurations
exception IndivisableDurations
exception ImpossibleDate
exception NoValueProvided of source_position

Value Embedding

type runtime_value =
  1. | Unit
  2. | Bool of bool
  3. | Money of money
  4. | Integer of integer
  5. | Decimal of decimal
  6. | Date of date
  7. | Duration of duration
  8. | Enum of string list * string * runtime_value
  9. | Struct of string list * (string * runtime_value) list
  10. | Array of runtime_value Stdlib.Array.t
  11. | Unembeddable
val unembeddable : 'a -> runtime_value
val embed_unit : unit -> runtime_value
val embed_bool : bool -> runtime_value
val embed_money : money -> runtime_value
val embed_integer : integer -> runtime_value
val embed_decimal : decimal -> runtime_value
val embed_date : date -> runtime_value
val embed_duration : duration -> runtime_value
val embed_array : ('a -> runtime_value) -> 'a Stdlib.Array.t -> runtime_value

Logging

type event =
  1. | BeginCall of string list
  2. | EndCall of string list
  3. | VariableDefinition of string list * runtime_value
  4. | DecisionTaken of source_position
val reset_log : unit -> unit
val retrieve_log : unit -> event list
val log_begin_call : string list -> ('a -> 'b) -> 'a -> 'b
val log_end_call : string list -> 'a -> 'a
val log_variable_definition : string list -> ('a -> runtime_value) -> 'a -> 'a
val log_decision_taken : source_position -> bool -> bool

Constructors and conversions

Money

val money_of_cents_string : string -> money
val money_of_units_int : int -> money
val money_of_cents_integer : integer -> money
val money_to_float : money -> float
val money_to_string : money -> string
val money_to_cents : money -> integer

Decimals

val decimal_of_string : string -> decimal
val decimal_to_string : max_prec_digits:int -> decimal -> string
val decimal_of_integer : integer -> decimal
val decimal_of_float : float -> decimal
val decimal_to_float : decimal -> float

Integers

val integer_of_string : string -> integer
val integer_to_string : integer -> string
val integer_to_int : integer -> int
val integer_of_int : int -> integer
val integer_log2 : integer -> int
val integer_exponentiation : integer -> int -> integer

Dates

val day_of_month_of_date : date -> integer
val month_number_of_date : date -> integer
val year_of_date : date -> integer
val date_to_string : date -> string
val date_of_numbers : int -> int -> int -> date

Usage: date_of_numbers year month day

Durations

val duration_of_numbers : int -> int -> int -> duration
val duration_to_years_months_days : duration -> int * int * int
val duration_to_string : duration -> string

Defaults

val handle_default : (unit -> 'a) array -> (unit -> bool) -> (unit -> 'a) -> 'a
val no_input : unit -> 'a

Operators

Money

val (*$) : money -> decimal -> money
val (/$) : money -> money -> decimal
  • raises Division_by_zero
val (+$) : money -> money -> money
val (-$) : money -> money -> money
val (~-$) : money -> money
val (=$) : money -> money -> bool
val (<=$) : money -> money -> bool
val (>=$) : money -> money -> bool
val (<$) : money -> money -> bool
val (>$) : money -> money -> bool

Integers

val (+!) : integer -> integer -> integer
val (-!) : integer -> integer -> integer
val (~-!) : integer -> integer
val (*!) : integer -> integer -> integer
val (/!) : integer -> integer -> integer
  • raises Division_by_zero
val (=!) : integer -> integer -> bool
val (>=!) : integer -> integer -> bool
val (<=!) : integer -> integer -> bool
val (>!) : integer -> integer -> bool
val (<!) : integer -> integer -> bool

Decimals

val (+&) : decimal -> decimal -> decimal
val (-&) : decimal -> decimal -> decimal
val (~-&) : decimal -> decimal
val (*&) : decimal -> decimal -> decimal
val (/&) : decimal -> decimal -> decimal
  • raises Division_by_zero
val (=&) : decimal -> decimal -> bool
val (>=&) : decimal -> decimal -> bool
val (<=&) : decimal -> decimal -> bool
val (>&) : decimal -> decimal -> bool
val (<&) : decimal -> decimal -> bool

Dates

val (+@) : date -> duration -> date
val (-@) : date -> date -> duration
val (=@) : date -> date -> bool
val (>=@) : date -> date -> bool
val (<=@) : date -> date -> bool
val (>@) : date -> date -> bool
val (<@) : date -> date -> bool

Durations

val (+^) : duration -> duration -> duration
val (-^) : duration -> duration -> duration
val (/^) : duration -> duration -> decimal
  • raises Division_by_zero
val (~-^) : duration -> duration
val (=^) : duration -> duration -> bool
val (>=^) : duration -> duration -> bool
val (<=^) : duration -> duration -> bool
val (>^) : duration -> duration -> bool
val (<^) : duration -> duration -> bool

Arrays

val array_filter : ('a -> bool) -> 'a array -> 'a array
val array_length : 'a array -> integer
OCaml

Innovation. Community. Security.