ribosome-0.9.9.9: Neovim plugin framework for Polysemy
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ribosome.Effect.Persist

Description

Persisting data across vim sessions

Synopsis

Documentation

data Persist a :: Effect where Source #

This effect abstracts storing data of type a in the file system to allow loading it when a plugin starts.

Each distinct type corresponds to a separate copy of this effect. When the same type should be stored in separate files for different components of the plugin, use Tagged. The subdirectory or file name used for a type is specified to the interpreter. If the constructor store is called with Just a file name, each value is stored in a separate file, otherwise the same file is overwritten on every call to store.

The default interpreter delegates file path resolution to the effect PersistPath and uses JSON to codec the data.

Constructors

Store :: Maybe (Path Rel File) -> a -> Persist a m ()

Store a value in the persistence file or, if the first argument is Just, in that file in the persistence directory.

Load :: Maybe (Path Rel File) -> Persist a m (Maybe a)

Load a value from the persistence file or, if the first argument is Just, from that file in the persistence directory. Returns Nothing if the file doesn't exist.

store :: forall a r. Member (Persist a) r => Maybe (Path Rel File) -> a -> Sem r () Source #

Store a value in the persistence file or, if the first argument is Just, in that file in the persistence directory.

load :: forall a r. Member (Persist a) r => Maybe (Path Rel File) -> Sem r (Maybe a) Source #

Load a value from the persistence file or, if the first argument is Just, from that file in the persistence directory. Returns Nothing if the file doesn't exist.

loadOr :: Member (Persist a) r => Maybe (Path Rel File) -> a -> Sem r a Source #

Load a value from the persistence file or, if the first argument is Just, from that file in the persistence directory. Returns the fallback value if the file doesn't exist.

loadSingle :: Member (Persist a) r => Sem r (Maybe a) Source #

Load a value from the persistence file. Returns Nothing if the file doesn't exist.

loadSingleOr :: Member (Persist a) r => a -> Sem r a Source #

Load a value from the persistence file. Returns the fallback value if the file doesn't exist.

loadPath :: Member (Persist a) r => Path Rel File -> Sem r (Maybe a) Source #

Load a value from the specified file in the persistence directory. Returns Nothing if the file doesn't exist.

loadPathOr :: Member (Persist a) r => Path Rel File -> a -> Sem r a Source #

Load a value from the specified file in the persistence directory. Returns the fallback value if the file doesn't exist.