package bap-std
- Overview
- No Docs
You can search for identifiers within the package.
in-package search v0.2.0
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=9c126781385d2fa9b8edab22e62b25c70bf2f99f6ec78abb7e5e36d63cfa4174
md5=5abd9b3628b43f797326034f31ca574f
doc/bap/Bap/Std/Value/Match/index.html
Module Value.Match
Runtime parallel match.
This module can be used to handle several cases in parallel instead of using a sequence of nested matches or if/then/else chains.
The combinators in the module are designed to be used as follows:
let lift v = Match.(begin
switch v @@
case memory_load (fun x -> `Load x) @@
case memory_store (fun x -> `Store x) @@
case register_read (fun x -> `Read x) @@
default (fun () -> `Unknown)
end)
Note: in the example, the whole expression will build and then match. In case when performance matter, and when there is more then one match, it is recommended to evaluate a matching object first, and return a function, that matches values. For this there is a select
combinator:
let lift =
Match.(begin
select @@
case memory_load (fun x -> `Load x) @@
case memory_store (fun x -> `Store x) @@
case register_read (fun x -> `Read x) @@
default (fun () -> `Unknown)
end)
select matcher x
applies matcher
to value x
. select
is the same as Fn.flip switch
.
case tag action matcher
adds an action
to matcher
that will be invoked for values with a a given tag
val default : (unit -> 's) -> 's t
default def
creates an empty matcher with default handler def
.