package catala

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Catala_utils.MessageSource

Interface for emitting compiler messages.

All messages are expected to use the Format module. Flush, "@?", "@.", "%!" etc. are not supposed to be used outside of this module.

WARNING: this module performs side-effects at load time, adding support for ocolor tags (e.g. "@{<blue>text@}") to the standard string formatter used by e.g. Format.sprintf. (In this case, the tags are ignored, for color output you should use the functions of this module that toggle support depending on cli flags and terminal support).

Message content

Sourcetype level =
  1. | Error
  2. | Warning
  3. | Debug
  4. | Log
  5. | Result
Sourcemodule Content : sig ... end

This functions emits the message according to the emission type defined by Cli.message_format_flag.

Error exception

Sourceexception CompilerError of Content.t

Some formatting helpers

Sourceval unformat : (Format.formatter -> unit) -> string

Converts f to a string, discarding formatting and skipping newlines and indents

Sourceval has_color : out_channel -> bool
Sourceval set_terminal_width_function : (unit -> int) -> unit
Sourceval formatter_of_out_channel : out_channel -> Format.formatter

Creates a new formatter from the given out channel, with correct handling of the ocolor tags. Actual use of escape codes in the output depends on Cli.style_flag -- and wether the channel is a tty if that is set to auto.

Simple interface for various message emission

Sourcetype ('a, 'b) emitter = ?header:Content.message -> ?internal:bool -> ?pos:Pos.t -> ?pos_msg:Content.message -> ?extra_pos:(string * Pos.t) list -> ?fmt_pos:(Content.message * Pos.t) list -> ?outcome:Content.message list -> ?suggestion:string list -> ('a, Format.formatter, unit, 'b) format4 -> 'a
Sourceval log : ('a, unit) emitter
Sourceval debug : ('a, unit) emitter
Sourceval result : ('a, unit) emitter
Sourceval warning : ('a, unit) emitter
Sourceval error : ('a, 'b) emitter
Sourceval results : Content.message list -> unit
OCaml

Innovation. Community. Security.