https://github.com/leostera/loop
Unbounded loops with early breaks and continues for OCaml 5.
https://github.com/leostera/loop
Last synced: 8 months ago
JSON representation
Unbounded loops with early breaks and continues for OCaml 5.
- Host: GitHub
- URL: https://github.com/leostera/loop
- Owner: leostera
- License: mit
- Created: 2023-11-13T01:22:06.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-13T01:35:52.000Z (over 2 years ago)
- Last Synced: 2025-03-21T01:11:11.479Z (over 1 year ago)
- Language: OCaml
- Homepage:
- Size: 4.88 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE.md
Awesome Lists containing this project
README
# loop
A small control-flow utility for unbounded loops with support for `break` and
`continue`ing loops.
By default it will loop infinitely, but it won't get in the way of unbounded
exceptions or other unhandled effects.
## Getting Started
```
opam install loop
```
## Usage
The usage should feel rather natural:
1. start a loop
2. call `continue` or `break` as you see fit
### Examples
Here's a small REPL:
```ocaml
let repl () =
let open Loop in
loop (fun () ->
let expr = read () in
let result = eval expr in
print result;
match result with
| Exit -> break ()
| _ -> ())
```