logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Local_store - This module provides some facilities for creating references (and hash tables) which can

Documentation

       Module Local_store
        : sigend

       This module provides some facilities for creating references  (and  hash  tables)  which  can  easily  be
       snapshotted 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.

   Creatorsvals_ref : 'a->'aref

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

       vals_table : ('a->'b)->'a->'bref

       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:
             letmy_table=s_tableHashtbl.create42Statemanagement
       Note: all the following functions are currently unused inside the compiler codebase. Merlin is their only
       user at the moment.

       typestorevalfresh : 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.

       valwith_store : store->(unit->'a)->'awith_storesf 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.

       valreset : unit->unit

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

       valis_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.

OCamldoc                                           2025-06-12                                    Local_store(3o)

Module

       Module   Local_store

Name

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

See Also