package eventually
All checked builds passInstall
dune-project
Dependency
Authors
Maintainers
Sources
md5=2ff603e740d1267316d1dcf3ce4e0c39
sha512=48cf12103dd2f67ffdaf9ab4d061432ccbaf1e36c454f9928c76abde58abb02076fecdb23538a16480c8485e449ad424d2205913483392b99619b3ed1503db38
Description
This package exposes the eventually monad for computations run against a logical time budget, which may be infinite (risking that the computation diverges) or finite (resulting in a timeout instead). The package provides a reader/writer interface for stream processing, and implements time-bounded stream operations by way of the eventually monad.
README
Eventually
A small OCaml library for imposing logical time bounds on computations that may otherwise diverge.
Usage
dune build # Build the library and executable
dune runtest # Run tests
dune exec eventually # Run a small demonstrationExamples
Time-bounded computation
An 'a Eventually.eventually is a computation subject to a logical time budget, which is consumed by way of Eventually.tick n.
let rec loop n =
let* () = Eventually.tick 1 in (* consume one tick *)
Printf.printf "tick %d\n" n; (* print "tick n" *)
match n with
| 0 -> Eventually.return "foo" (* if `n=0` then return "foo" *)
| _ -> loop (n - 1) (* else decrement `n` and repeat *)Timer.incr n Timer.zero supplies a budget of n ticks.
(* Prints "tick 3", "tick 2".
Returns `Eventually.Timeout`. *)
let _ = Eventually.run (Timer.incr 2 Timer.zero) (loop 3)
(* Prints "tick 3", "tick 2", "tick 1", "tick 0".
Returns `Eventually.Success "foo"`. *)
let _ = Eventually.run (Timer.incr 5 Timer.zero) (loop 3)
(* Prints "tick -4", "tick -5".
Returns `Eventually.Timeout`. *)
let _ = Eventually.run (Timer.incr 2 Timer.zero) (loop -4)Timer.forever supplies infinitely many ticks.
(* Prints "tick 3", "tick 2", "tick 1", "tick 0".
Returns `Eventually.Success "foo"`. *)
let _ = Eventually.run (Timer.forever) (loop 3)
(* Prints "tick -4", "tick -5", "tick -6", "tick -7"...
The computation diverges. *)
let _ = Eventually.run (Timer.forever) (loop -4)Project layout
lib/ The Timer, Eventually, and Supply library modules
bin/ The Hailstone Sequence and Newton's Method demonstration executable
test/ Package tests
Dev Dependencies (1)
-
odoc
with-doc
Optional Dependencies
None
Used by
None
Conflicts
None
Build status
Results of building eventually with each compiler on check.ci.ocaml.org, run of against opam-repository efadaba. All results for this package.
Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.
| Version | OCaml 4.11 | OCaml 4.14 | OCaml 5.2 | OCaml 5.4 | OCaml 5.5 |
|---|---|---|---|---|---|
| 0.2.0 (this version) | n/a | good | good | good | good |
- good Package successfully built
- partial One of the dependencies failed to build
- bad Package failed to build
- n/a Package is not available in this environment
- internal Internal failure