package alba

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

A readable printer is a structure you can issue print commands on and which returns a readable structure which can be read character by character.

Principles

A readable printer is a very lightweight and lazy structure. Issuing a command like string "hello" just stores the string and does nothing else.

Since the printer is organized as a monoid you chain to printers p1 and p2 by p1 <+> p2.

If you printed all your stuff to the printer p you use readable p to generate a readable structure. The readable structure is lazy as well. It just has the first item (string, substring, fill or character) explicitly and a function to generate the rest if needed. So the actual output is generated on demand.

Readable Structure

The readable structure returned by the printer.

Basics

type t

The type of a readable printer.

val empty : t

The readable printer printing nothing.

val (<+>) : t -> t -> t

p1 <+> p2 prints first p1 and then p2.

val string : string -> t

string s prints the string s.

val substring : string -> int -> int -> t

substring s start len prints the substring of s starting at position start with length len.

val fill : int -> char -> t

fill n c prints the character c n times.

val char : char -> t

char c prints the character c.

Generate the Readable Structure

val readable : t -> R.t

readable p generates a readable structure from the printer p.

OCaml

Innovation. Community. Security.