Module Acutis

This is the main API wrapper around the compiler internals (Acutis_internals).

type message

An error message.

type 'a compile_result := message list * 'a option

The result of a compile computation. The first value is a list of warnings and error messages. If the second value is Some then the computation succeeded. If None, then it failed for the reasons in the messages. A successful computation may have warning messages.

type interface

Type interfaces for templates.

type parsed

A template that's been parsed but not type-checked, optimized, or linked yet.

type 'a comp

A template component. Parameter 'a is the type of external components, which may either be a function or a js_import.

type 'a comps_compiled

A group of compiled and linked components.

type 'a compiled

A completely compiled template.

Compiling templates.

val comp_of_parsed : string -> parsed -> 'a comp

Convert a parsed Acutis template into a component. The string is the name the component is called in Acutis code.

val comp_of_fun : string -> interface -> 'a -> 'a comp

Convert a function or a js_import into a template component. The string is the name the component is called in Acutis code.

val comps_compile : 'a comp Stdlib.Seq.t -> 'a comps_compiled compile_result

Type-check, optimize, and link the components.

val comps_empty : 'a comps_compiled
val parse : Stdlib.Lexing.lexbuf -> parsed compile_result

Parse a component. This does not type-check, optimize, or link yet.

val compile : 'a comps_compiled -> parsed -> 'a compiled compile_result

Type-check, optimize, and link the template with its components.

val compile_interface : Stdlib.Lexing.lexbuf -> interface compile_result

Parse and type-check a type interface with no template.

val get_interface : 'a compiled -> interface

Working with decodable data and rendering templates in OCaml.

module type DECODABLE = sig ... end

A specification for decoding and encoding input data.

module Of_decodable (D : DECODABLE) : sig ... end

A functor that builds functions to render templates and construct type interfaces from decodable data.

Printing templates as JavaScript modules.

type js_import

Information to import an external JavaScript function.

val js_import : module_path:string -> function_path:string -> js_import
val cjs : Stdlib.Format.formatter -> js_import compiled -> unit

Print a template as a CommonJS module.

val esm : Stdlib.Format.formatter -> js_import compiled -> unit

Print a template as an ECMAScript module.

Handling errors and printing debug information.

val pp_message : Stdlib.Format.formatter -> message -> unit

Pretty-print an error message.

val pp_interface : Stdlib.Format.formatter -> interface -> unit

Pretty-print a type interface in Acutis syntax.

val pp_ast : Stdlib.Format.formatter -> parsed -> unit

Pretty-print a template's abstract syntax tree in S-expression syntax.

val pp_compiled : Stdlib.Format.formatter -> _ compiled -> unit

Pretty-print a fully-compiled template in S-expression syntax.

val pp_instructions : (Stdlib.Format.formatter -> 'a -> unit) -> Stdlib.Format.formatter -> 'a compiled -> unit

Pretty-print runtime instructions in S-expression syntax.

val pp_js_import : Stdlib.Format.formatter -> js_import -> unit

Pretty-print JavaScript import data in S-expression syntax.