| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Ribosome.Effect.Persist
Description
Persisting data across vim sessions
Synopsis
- data Persist a :: Effect where
- store :: forall a r. Member (Persist a) r => Maybe (Path Rel File) -> a -> Sem r ()
- load :: forall a r. Member (Persist a) r => Maybe (Path Rel File) -> Sem r (Maybe a)
- loadOr :: Member (Persist a) r => Maybe (Path Rel File) -> a -> Sem r a
- loadSingle :: Member (Persist a) r => Sem r (Maybe a)
- loadSingleOr :: Member (Persist a) r => a -> Sem r a
- loadPath :: Member (Persist a) r => Path Rel File -> Sem r (Maybe a)
- loadPathOr :: Member (Persist a) r => Path Rel File -> a -> Sem r a
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 |
| Load :: Maybe (Path Rel File) -> Persist a m (Maybe a) | Load a value from the persistence file or, if the first argument is |
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.
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.