Runtime_ocaml.Runtime
The OCaml runtime.
exception AssertionFailed of source_position
exception ConflictError of source_position
exception NoValueProvided of source_position
type runtime_value =
| Unit |
| Bool of bool |
| Money of money |
| Integer of integer |
| Decimal of decimal |
| Date of date |
| Duration of duration |
| Enum of string list * string * runtime_value |
| Struct of string list * (string * runtime_value) list |
| Array of runtime_value Stdlib.Array.t |
| Unembeddable |
val yojson_of_runtime_value :
runtime_value ->
Ppx_yojson_conv_lib.Yojson.Safe.t
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
The logging is constituted of two phases:
raw_event
) during the program execution (see retrieve_log
) throught Logging instruments.event
).Represents information about a name in the code -- i.e. variable name, subscope name, etc...
It's a list of strings with a length varying from 2 to 3, where:
Scope_name
,a_subscope_var.input_var
Subscope_name
or, the input
(resp. output
) string -- which corresponds to the input (resp. the output) of a function.val yojson_of_information : information -> Ppx_yojson_conv_lib.Yojson.Safe.t
type raw_event =
| BeginCall of information | (* Subscope or function call. *) |
| EndCall of information | (* End of a subscope or a function call. *) |
| VariableDefinition of information * runtime_value | (* Definition of a variable or a function argument. *) |
| DecisionTaken of source_position | (* Source code position of an event. *) |
The corresponding grammar of the event
type, is the following:
<event> := <fun_call> | <subscope_call> | <var_def> | <var_def_with_fun> | VariableDefinition <fun_call> := VariableDefinition (function input) <fun_call_beg> <event>* (<var_def> | <var_def_with_fun>) (function output) EndCall <var_def_with_fun> := /-- DecisionTaken pos of | <fun_call>+ (function calls needed to compute the variable value) \-> VariableDefinition <subscope_call> := <sub_var_def>* (sub-scope attributes def) <sub_call_beg> <event>+ EndCall <var_def> := DecisionTaken VariableDefinition(info, _) (when info.length = 2 && info[1] == "id") <sub_var_def> := DecisionTaken VariableDefinition(info, _) (when info.length = 3) <fun_call_beg> := BeginCall(info) (when info.length = 2) <sub_call_beg> := BeginCall(info) (when info.length = 2 and '.' in info[1])
type event =
| VarComputation of var_def | |||
| FunCall of fun_call | |||
| SubScopeCall of {
} |
and var_def = {
pos : source_position option; |
name : information; |
value : runtime_value; |
fun_calls : fun_call list option; |
}
and fun_call = {
fun_name : information; |
fun_inputs : var_def list; |
body : event list; |
output : var_def; |
}
val yojson_of_event : event -> Ppx_yojson_conv_lib.Yojson.Safe.t
val yojson_of_var_def : var_def -> Ppx_yojson_conv_lib.Yojson.Safe.t
val yojson_of_fun_call : fun_call -> Ppx_yojson_conv_lib.Yojson.Safe.t
val retrieve_log : unit -> raw_event list
retrieve_log ()
returns the current list of collected raw_event
.
module EventParser : sig ... end
val log_variable_definition :
string list ->
( 'a -> runtime_value ) ->
'a ->
'a
val log_decision_taken : source_position -> bool -> bool
val pp_events :
?is_first_call:bool ->
Stdlib.Format.formatter ->
event list ->
unit
pp_events ~is_first_call ppf events
pretty prints in ppf
the string representation of events
.
If is_first_call
is set to true, the formatter will be flush at the end. By default, is_first_call
is set to false.
val money_of_cents_string : string -> money
val money_of_units_int : int -> money
val money_to_float : money -> float
val money_to_string : money -> string
val decimal_of_string : string -> decimal
val decimal_to_string : max_prec_digits:int -> decimal -> string
val decimal_of_float : float -> decimal
val decimal_to_float : decimal -> float
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 is_leap_year : integer -> bool
val date_to_string : date -> string
val date_of_numbers : int -> int -> int -> date
Usage: date_of_numbers year month day
val duration_of_numbers : int -> int -> int -> duration
Usage : duration_of_numbers year mounth day
.
val duration_to_years_months_days : duration -> int * int * int
Times
val duration_to_string : duration -> string
val handle_default :
source_position ->
( unit -> 'a ) array ->
( unit -> bool ) ->
( unit -> 'a ) ->
'a
val handle_default_opt :
source_position ->
'a eoption array ->
( unit -> bool eoption ) ->
( unit -> 'a eoption ) ->
'a eoption
module Oper : sig ... end