package merlin-lib
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=2cea46f12397fa6e31ef0c0d4f5e11c1cfd916ee49420694005c95ebb3aa24bc
sha512=e94abb9ae38149245337db033e2c3891c7ec772168e99abf1bda0216a894c0854e7170b56fe88eba83ec98f2ebc0f5c7c723e8db14f59eeb6dd348bec12c6d62
doc/merlin-lib.ocaml_utils/Ocaml_utils/Local_store/index.html
Module Ocaml_utils.Local_store
Source
This module provides some facilities for creating references (and hash tables) which can easily be snapshoted and restored to an arbitrary version.
It is used throughout the frontend (read: typechecker), to register all (well, hopefully) the global state. Thus making it easy for tools like Merlin to go back and forth typechecking different files.
Creators
Similar to Stdlib.ref
, except the allocated reference is registered into the store.
Used to register hash tables. Those also need to be placed into refs to be easily swapped out, but one can't just "snapshot" the initial value to create fresh instances, so instead an initializer is required.
Use it like this:
let my_table = s_table Hashtbl.create 42
State management
Note: all the following functions are currently unused inside the compiler codebase. Merlin is their only user at the moment.
Returns a fresh instance of the store.
The first time this function is called, it snapshots the value of all the registered references, later calls to fresh
will return instances initialized to those values.
with_store s f
resets all the registered references to the value they have in s
for the run of f
. If f
updates any of the registered refs, s
is updated to remember those changes.
Resets all the references to the initial snapshot (i.e. to the same values that new instances start with).
Returns true
when a store is active (i.e. when called from the callback passed to with_store
), false
otherwise.