package liquidsoap-lang

  1. Overview
  2. Docs

Values and types of the liquidsoap language.

type t = Type.t

The type of a value.

type module_name
type scheme = Type.scheme
type regexp

Values

module Ground : sig ... end

A typed value.

module Methods = Term.Methods
type value = Value.t = {
  1. pos : Pos.Option.t;
  2. value : in_value;
  3. methods : value Methods.t;
}
and env = (string * value) list
and lazy_env = (string * value Lazy.t) list
and in_value = Value.in_value =
  1. | Ground of Ground.t
  2. | List of value list
  3. | Tuple of value list
  4. | Null
  5. | Fun of (string * string * value option) list * lazy_env * Term.t
  6. | FFI of (string * string * value option) list * env -> value
val demeth : value -> value
val split_meths : value -> (string * value) list * value

Computation

val apply_fun : (?pos:Pos.t -> value -> env -> value) ref
val apply : value -> env -> value

Multiapply a value to arguments. The argument t is the type of the result of the application.

Helpers for source builtins

type proto = (string * t * value option * string option) list
val add_builtin : category:Doc.Value.category -> descr:string -> ?flags:Doc.Value.flag list -> ?meth:(string * Type.scheme * string * value) list -> ?examples:string list -> ?base:module_name -> string -> proto -> t -> (env -> value) -> module_name

Add a builtin to the language, high-level version for functions.

val add_builtin_value : category:Doc.Value.category -> descr:string -> ?flags:Doc.Value.flag list -> ?base:module_name -> string -> value -> t -> module_name

Add a builtin value to the language

val add_builtin_base : category:Doc.Value.category -> descr:string -> ?flags:Doc.Value.flag list -> ?base:module_name -> string -> in_value -> t -> module_name

Add a builtin to the language, more rudimentary version.

val add_module : ?base:module_name -> string -> module_name

Declare a new module.

val module_name : module_name -> string

Manipulation of values

val to_unit : value -> unit
val to_bool : value -> bool
val to_bool_getter : value -> unit -> bool
val to_string : value -> string
val to_string_getter : value -> unit -> string
val to_regexp : value -> regexp
val to_float : value -> float
val to_float_getter : value -> unit -> float
val to_int : value -> int
val to_int_getter : value -> unit -> int
val to_num : value -> [ `Int of int | `Float of float ]
val to_list : value -> value list
val to_option : value -> value option
val to_valued_option : (value -> 'a) -> value -> 'a option
val to_default_option : default:'a -> (value -> 'a) -> value -> 'a
val to_product : value -> value * value
val to_tuple : value -> value list
val to_ref : value -> (unit -> value) * (value -> unit)
val to_valued_ref : (value -> 'a) -> ('a -> value) -> value -> (unit -> 'a) * ('a -> unit)
val to_string_list : value -> string list
val to_int_list : value -> int list
val to_fun : value -> (string * value) list -> value
val to_getter : value -> unit -> value
val assoc : 'a -> int -> ('a * 'b) list -> 'b

assoc x n l returns the n-th y such that (x,y) is in the list l. * This is useful for retrieving arguments of a function.

val int_t : t
val unit_t : t
val float_t : t
val bool_t : t
val string_t : t
val regexp_t : t
val product_t : t -> t -> t
val of_product_t : t -> t * t
val tuple_t : t list -> t
val of_tuple_t : t -> t list
val record_t : (string * t) list -> t
val optional_record_t : (string * t) list -> t
val method_t : t -> (string * scheme * string) list -> t
val optional_method_t : t -> (string * scheme * string) list -> t
val list_t : t -> t
val of_list_t : t -> t
val nullable_t : t -> t
val ref_t : t -> t
val error_t : t
val fun_t : (bool * string * t) list -> t -> t

fun_t args r is the type of a function taking args as parameters * and returning values of type r. * The elements of r are of the form (b,l,t) where b indicates if * the argument is optional, l is the label of the argument ("" means no * label) and t is the type of the argument.

val univ_t : ?constraints:Type.constr list -> unit -> t
val getter_t : t -> t

A getter on an arbitrary type.

val unit : value
val int : int -> value
val bool : bool -> value
val float : float -> value
val string : string -> value
val regexp : regexp -> value
val list : value list -> value
val null : value
val product : value -> value -> value
val tuple : value list -> value
val meth : value -> (string * value) list -> value
val record : (string * value) list -> value
val reference : (unit -> value) -> (value -> unit) -> value
val val_fun : (string * string * value option) list -> (env -> value) -> value

Build a function from an OCaml function. Items in the prototype indicate the label and optional values. Second string value is used when renaming argument name, e.g. `fun (foo=_, ...) -> `

val term_fun : (string * string * value option) list -> Term.t -> value

Build a function from a term.

val val_cst_fun : (string * value option) list -> value -> value

Build a constant function. * It is slightly less opaque and allows the printing of the closure * when the constant is ground.

val pos : env -> Pos.t list

Extract position from the environment. Used inside function execution.

val raise_error : ?bt:Printexc.raw_backtrace -> ?message:string -> pos:Pos.List.t -> string -> 'a

Raise an error.

val runtime_error_of_exception : bt:Printexc.raw_backtrace -> kind:string -> exn -> Runtime_error.runtime_error

Convert an exception into a runtime error.

val raise_as_runtime : bt:Printexc.raw_backtrace -> kind:string -> exn -> 'a

Re-raise an error as a runtime error.

val environment : unit -> (string * string) list

Return the process' environment.

val descr_of_regexp : regexp -> string

Return an unescaped string description of a regexp, i.e. ^foo/bla$

val string_of_regexp : regexp -> string

Return a string description of a regexp value i.e. r/^foo\/bla$/g

module Regexp : sig ... end
OCaml

Innovation. Community. Security.