package rich-string

  1. Overview
  2. Docs
The rich-string library provides a generic way to enrich the built-in string type with new capabilities

Install

dune-project
 Dependency

Authors

Maintainers

Sources

rich-string-1.0.0.tbz
sha256=f376e4ffc99b2991813919dc36fe3f8ac86cc48e64b062151dd97da1ae7153a0
sha512=e5b5512cada9529a4f2415b8112a533204c83ea7ca69a4bd89201c9af04cefc0b009e7f9c4e48e00a06dfcf0dd1c62048555e452766e1bad712751da46809b69

doc/rich-string/Rich_string/index.html

Module Rich_stringSource

A string type equipped with an enricher.

It is a generalization of the idea of augmenting the built- in string type with capabilities which are provided by the aforementioned enricher. Rich strings are cumulative: you can always equip it with more enrichers!

For example, the enricher can be an ANSI style type, giving the ability of colors and other text decorations in the terminal to strings.

Such rich string type preserves the monoidal properties of strings, that is, there is an empty string (Empty) as well as a compositional operator (++) that satisfies the laws of identity (Empty ++ s = s ++ Empty = s) and associativity ((s1 ++ s2) ++ s3 = s1 ++ (s2 ++ s3)).

Note: This implementation optimizes for the case of joining a list of rich strings together over simple, pairwise concatenation as the former is much more prevalent.

As such, ( ++ ) is optimized to reuse lists and keep the structure flat as much as possible. Tests must (and will) make sure that monoidal laws are preserved.

Sourcemodule type ENRICHER = sig ... end

An ENRICHER is a type that represents a capability that can be added to strings.

Sourcemodule type TYPE = sig ... end

The type of a rich string.

Sourcemodule Make (Enricher : ENRICHER) : TYPE with module Enricher = Enricher

Given an Enricher type, constructs a rich string type.