package asai

  1. Overview
  2. Docs

The minimum interface for libraries and applications to work together.

If you are the author of a library that uses asai, it is recommended to wrap your reporter with this signature in the wrapper. For example, if you are using Dune, and your wrapper file is CoolLibrary.ml(i), use this to wrap your Reporter:

module Reporter : Asai.MinimumSigs.Reporter

If you arrive here because the library you are using employs this template signature to reveal only the minimum API, you can write the following code to connect the library's reporter to yours:

Reporter.adopt (Diagnostic.map message_mapper) CoolLibrary.Reporter.run @@ fun () -> ...

Please take a look at our Quick Start Tutorial about how to use a library that uses asai.

module Message : Message

The module for messages.

val run : ?init_loc:Range.t -> ?init_backtrace:Diagnostic.backtrace -> emit:(Message.t Diagnostic.t -> unit) -> fatal:(Message.t Diagnostic.t -> 'a) -> (unit -> 'a) -> 'a

run ~emit ~fatal f runs the thunk f, using emit to handle non-fatal diagnostics before continuing the computation, and fatal to handle fatal diagnostics that have aborted the computation. The recommended way to handle messages from a library that uses asai is to use adopt:

Reporter.adopt (Diagnostic.map message_mapper) The_library.Reporter.run @@ fun () -> ...
  • parameter init_loc

    The initial default location for messages.

  • parameter init_backtrace

    The initial backtrace to start with. The default value is the empty backtrace.

  • parameter emit

    The handler of non-fatal diagnostics.

  • parameter fatal

    The handler of fatal diagnostics.