Programming
error.on_error
Register a callback to monitor errors raised during the execution of the program. The callback is allow to re-raise a different error if needed. The callback passed to this function is called on every errors, not just uncaught errors.
Type:
(((error
.{
kind : string,
message : string,
trace : [
{
cstart : int,
cstop : int,
filename : string,
lstart : int,
lstop : int,
to_string : (?prefix : string) -> string
}]
}) -> unit)) -> unit
Arguments:
(unlabeled)(of type(error .{ kind : string, message : string, trace : [ { cstart : int, cstop : int, filename : string, lstart : int, lstop : int, to_string : (?prefix : string) -> string }] }) -> unit)
error.raise
Raise an error.
Type:
(error, ?string) -> 'a
Arguments:
(unlabeled)(of typeerror): Error kind.(unlabeled)(of typestring, which defaults to""): Description of the error.
error.register
Register an error of the given kind
Type:
(string) -> error
Arguments:
(unlabeled)(of typestring): Kind of the error
Methods:
kind(of typestring): Error kind.message(of typestring): Error message.trace(of type[ { cstart : int, cstop : int, filename : string, lstart : int, lstop : int, to_string : (?prefix : string) -> string }]): Error stacktrace.
fst
Get the first component of a pair.
Type:
(('a * 'b)) -> 'a
Arguments:
(unlabeled)(of type'a * 'b)
ignore
Convert anything to unit, preventing warnings.
Type:
('a) -> unit
Arguments:
(unlabeled)(of type'a)
null
Create a nullable value.
Type:
(?'a) -> 'a?
Arguments:
(unlabeled)(of type'a, which defaults tonull): Value to make nullable.
null.case
Return a result dending on whether a value is nothing or not.
Type:
('a?, (() -> 'b), (('a) -> 'b)) -> 'b
Arguments:
(unlabeled)(of type'a?): Value to reason by case analysis on.(unlabeled)(of type() -> 'b): Value to return in case we have nothing.(unlabeled)(of type('a) -> 'b): Value to return in case we have something.
null.default
Return a result dending on whether a value is nothing or not.
Type:
('a?, (() -> 'a)) -> 'a
Arguments:
(unlabeled)(of type'a?): Value to reason by case analysis on.(unlabeled)(of type() -> 'a): Value to return in case we have nothing.
position
Return the current position in the script
Type:
() -> unit
Methods:
cstart(of typeint): Starting charactercstop(of typeint): Stopping characterfilename(of typestring): Filenamelstart(of typeint): Starting linelstop(of typeint): Stopping lineto_string(of type(?prefix : string) -> string): Render as string
print
Print on standard output.
Type:
(?newline : bool, 'a) -> unit
Arguments:
newline(of typebool, which defaults totrue): If true, a newline is added after displaying the value.(unlabeled)(of type'a)
ref
Create a reference, i.e. a value which can be modified.
Type:
('a) -> () -> 'a
Arguments:
(unlabeled)(of type'a)
Methods:
set(of type('A) -> unit): Set the value of the reference.
snd
Get the second component of a pair.
Type:
(('a * 'b)) -> 'b
Arguments:
(unlabeled)(of type'a * 'b)
sqlite
Manipulate an SQLITE database.
Type:
(string) -> unit
Arguments:
(unlabeled)(of typestring): File where the data base is stored
Methods:
close(of type() -> unit): Close the database. It should not be accessed afterward.exec(of type(string) -> unit): Execute an SQL operation.insert(of type(table : string, ?replace : bool, 'A) -> unit where 'A is a record with int, float, string or null methods.): Insert a value represented as a record into a table.iter(of type(((sqlite.row.{to_list : () -> [string * string?]}) -> unit), string) -> unit): Iterate a function over all the results of a query. Result can be parsed usinglet sqlite.row = ....query(of type(string) -> [sqlite.row.{to_list : () -> [string * string?]}]): Execute an SQL operation returning the result. Result can be parsed usinglet sqlite.query = ....
sqlite.escape
Escape a string for use in a query.
Type:
(string) -> string
Arguments:
(unlabeled)(of typestring): String to escape.
thread.delay
Delay the current thread by the given duration in seconds.
Type:
(float) -> unit
Arguments:
(unlabeled)(of typefloat)
thread.on_error
Register the function to be called when an error of the given kind is raised in a thread. Catches all errors if first argument is null.
Type:
(error?, ((backtrace : string, error) -> unit)) -> unit
Arguments:
(unlabeled)(of typeerror?)(unlabeled)(of type(backtrace : string, error) -> unit)
thread.pause
Pause execution for a given amount of seconds. This puts the calling thread to sleep and should not be used in the main streaming loop.
Type:
(float) -> unit
Arguments:
(unlabeled)(of typefloat): Number of seconds of pause.
thread.run.recurrent
Run a recurrent function in a separate thread.
Type:
(?fast : bool, ?delay : float, ?on_error : ((error) -> float)?,
(() -> float)) -> unit
Arguments:
fast(of typebool, which defaults totrue): Whether the thread is supposed to return quickly or not. Typically, blocking tasks (e.g. fetching data over the internet) should not be considered to be fast. When set tofalseits priority will be lowered below that of request resolutions and fast timeouts. This is only effective if you set a dedicated queue for fast tasks, see the "scheduler" settings for more details.delay(of typefloat, which defaults to0.0): Delay (in sec.) after which the thread should be launched.on_error(of type((error) -> float)?, which defaults tonull): Error callback executed when an error occurred while running the given function. When passed, all raised errors are silenced unless re-raised by the callback.(unlabeled)(of type() -> float): Function to execute recurrently. The returned value is the delay (in sec.) in which the function should be run again (it won't be run if the value is strictly negative).
while
A while loop.
Type:
({bool}, (() -> unit)) -> unit
Arguments:
(unlabeled)(of type{bool}): Condition guarding the loop.(unlabeled)(of type() -> unit): Function to execute.