All Projects → yallop → ocaml-syb

yallop / ocaml-syb

Licence: MIT license
Scrap Your Boilerplate for OCaml with modular implicits

Programming Languages

ocaml
1615 projects
Makefile
30231 projects

A port of the Scrap Your Boilerplate library to OCaml with modular implicits.

Installation

opam switch 4.02.0+modular-implicits
opam pin add syb https://github.com/yallop/ocaml-syb.git

Usage

The following examples assume that you have loaded the package and brought the instances into scope:

# #require "syb";;
# open Syb.Instances;;

Apply succ to every int within a larger structure:

# Syb.(everywhere (mkT succ)) [1;2;3];;
- : int list = [2; 3; 4]

Apply not to every bool within a larger structure:

# Syb.(everywhere (mkT not)) [[true], 1; [], 2; [true; false], 3];;
- : (bool list * int) list = [([false], 1); ([], 2); ([false; true], 3)]

Collect all int values less than 3:

# Syb.listify (fun x -> x < 3) [[(4, true)]; [(-2, false); (1, false)]; []; [0, true]];;
- : int list = [-2; 1; 0]

See also

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].