package ravel
All checked builds passInstall
dune-project
Dependency
Authors
Maintainers
Sources
sha256=44671583093c507a8352ac40e8eef67c3d2c26b1865d2aabf3efc89621131a69
sha512=a9c5fda04e2c9b1aed50bc42e818234830823aee373a666d100d1fc8349899f3faafc1bf987ff1fc71d31d6bdef091b32167cadb86f593bda8f3d0b1e510e95d
Description
Ravel supports algebraic data, deep pattern matching, first-class closures, and labeled duplication on an interaction-net runtime.
Added to opam-repository:
README
Ravel
Ravel is a small functional language that compiles to interaction nets.
Features
- User-defined constructor families with
data - Deep, multi-argument pattern matching
- First-class named functions, lambdas, and lexical closures
- Recursive and mutually recursive functions
- Automatic labeled
DupandErainsertion - Explicit
dupanddropfor low-level control - Deterministic or random interaction-net reduction
Syntax
program ::= typedef* definition* expr
typedef ::= data TYPE_NAME = CONSTRUCTOR ('|' CONSTRUCTOR)*
definition ::= def NAME(pattern[, pattern ...]) = expr
pattern ::= 0
| succ(pattern)
| CONSTRUCTOR(pattern, ...)
| CONSTRUCTOR
| NAME
| _
expr ::= INT
| NAME
| CONSTRUCTOR
| succ(expr)
| expr(expr, ...)
| CONSTRUCTOR(expr, ...)
| fun(NAME[, NAME ...]) = expr
| let NAME = expr in expr
| dup expr as NAME, NAME in expr
| drop expr in expr
| (expr)A data declaration groups constructor names. Constructor arities are inferred from usage. Declared families are checked for exhaustive matching; built-in Nat = Z | S uses the same mechanism.
Example
data Option = None | Some
def map_option(f, None) = None
def map_option(f, Some(value)) = Some(f(value))
def twice(f, value) = f(f(value))
def make_adder(offset) = fun(value) = add(offset, value)
let add_two = make_adder(2) in
twice(add_two, 3)Variables do not require manual resource management. The compiler inserts:
Erafor zero uses- a direct wire for one use
- a fresh labeled
Duptree for multiple uses
Explicit dup and drop remain supported.
Build and test
Install the opam-managed dependencies, then build with Dune:
opam install . --deps-only --with-test
make
make testInstall for the current user:
make installRun
ravel examples/closures.rvl
ravel -e "let f = fun(x) = succ(x) in f(4)"Useful options:
ravel --trace examples/closures.rvl
ravel --dump-ast examples/closures.rvl
ravel --dump-net examples/closures.rvl
ravel --strategy random --seed 42 examples/closures.rvlExamples
examples/closures.rvl— closures and higher-order functionsexamples/adt_tree_lookup.rvl— recursive ADTs and optional resultsexamples/deep_patterns.rvl— nested constructor matchingexamples/multi_argument_patterns.rvl— matching across argumentsexamples/fact.rvl— recursive arithmeticexamples/logic_arith.rvl— arithmetic predicatesexamples/work_pool.rvl— independent concurrent reductions
Dev Dependencies
None
Optional Dependencies
None
Used by
None
Conflicts
None
Build status
Results of building ravel with each compiler on check.ci.ocaml.org, run of against opam-repository 8a77e58. 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 |
|---|---|---|---|---|---|
| 1.0.1 (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