ppx_monoid

Syntax extension for building values of monoids
README

This is a syntax extension for OCaml to make building values of
monoids easier. Assumes the existence of two operations in scope for
some type t:

empty : t
(^^)  : t -> t -> t

ppx-monoid, triggered by the PPX extension point monoid,
reinterprets the semicolon ; to mean the monoid operation ^^ and
the unit expression () to mean empty.

Example:

let empty = "" and (^^) = (^) in
begin%monoid
  "hello";
  " ";
  "world"
end

is translated to:

let empty = "" and (^^) = (^) in
"hello" ^^ " " ^^ "world"

It is also possible to use concat or concatenate instead of
monoid:

let empty = "" and (^^) = (^) in
begin%concat   (* or 'concatenate' *)
  "hello";
  " ";
  "world"
end

See the test/test.ml file for more examples of usage, and for
examples of how the translation interacts with if then else and
match expressions.

The main use case for this syntax extension is for writing code that
generates HTML which consists of long sequences of concatenated bits
of HTML.

Install
Published
29 Jul 2022
Sources
v0.3.3.tar.gz
md5=a3080fb7b473bfebcb8724b53df1c27f
sha512=b2ac2c291dd0ade2aad61d78a5dd82a2dc4fd51d5455f4419481c2c26e2acb26753926a2581f55f2bd2b10b25159e7d7b87f5fef67b5315d799d2a86de359f50
Dependencies
odoc
with-doc
ounit
with-test
ppxlib
>= "0.27.0"
ocaml
>= "4.04.1"
dune
>= "2.7"
Reverse Dependencies