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=7c6d0dfe2640e800829617dd150ffe748493fe3f317ed41be44312b2821deb46
md5=5dbc6677d646bec59fd7414f23e88cf8
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 tdefault def creates an empty matcher with default handler def.