GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Local_store(3) OCaml library Local_store(3)

Local_store - This module provides some facilities for creating references (and hash tables) which can easily be snapshoted and restored to an arbitrary version.

Module Local_store

Module Local_store
: sig end

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.

val s_ref : 'a -> 'a ref

Similar to ref , except the allocated reference is registered into the store.

val s_table : ('a -> 'b) -> 'a -> 'b ref

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

Note: all the following functions are currently unused inside the compiler codebase. Merlin is their only user at the moment.

type store

val fresh : unit -> store

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.

val with_store : store -> (unit -> 'a) -> 'a

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.

val reset : unit -> unit

Resets all the references to the initial snapshot (i.e. to the same values that new instances start with).

val is_bound : unit -> bool

Returns true when a store is active (i.e. when called from the callback passed to Local_store.with_store ), false otherwise.

2025-07-03 OCamldoc

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.