package rich-string
Install
dune-project
Dependency
Authors
Maintainers
Sources
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.
An ENRICHER is a type that represents a capability that can be added to strings.