ssirai / ocaml-syb

Scrap Your Boilerplate for OCaml with modular implicits

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A port of the Scrap Your Boilerplate library to OCaml.

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]

About

Scrap Your Boilerplate for OCaml with modular implicits

License:MIT License


Languages

Language:OCaml 95.9%Language:Makefile 4.1%