c-cube / choice

Choice operator in OCaml, providing a backtracking monad

Home Page:https://c-cube.github.io/choice/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Choice build

Choice monad. See the Haskell library or this paper

See online documentation.

Example

> #require "choice";;
> open Choice.Infix;;
> let c = Choice.lift2 (fun x y -> x,y)
  (Choice.of_list [1;2;3;4]) (Choice.of_list ["1"; "3"]);;
val c : (int * string) Choice.t = <abstr>
> let c2 = Choice.filter c (fun (x,y) -> x = int_of_string y);;
val c2 : (int * string) Choice.t = <abstr>
> let c3 = Choice.take 2 c2;;
val c3 : (int * string) Choice.t = <abstr>
> Choice.run_n 4 c3;;
- : (int * string) list = [(3, "3"); (1, "1")]

Build

You need OCaml >= 4.03.0 and dune.

$ make
$ make install

License

The code is free, released under the BSD-2 license.

About

Choice operator in OCaml, providing a backtracking monad

https://c-cube.github.io/choice/

License:BSD 2-Clause "Simplified" License


Languages

Language:OCaml 97.5%Language:Makefile 2.5%