Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Interpreters for Persist
Synopsis
- persistBase :: Members [PersistPath !! PersistPathError, Stop PersistError] r => Sem r (Path Abs Dir)
- loadFile :: FromJSON a => Members [Stop PersistError, Log, Embed IO] r => Path Abs File -> Sem r a
- filepath :: Members [PersistPath !! PersistPathError, Stop PersistError] r => Path Rel File -> Path Rel Dir -> Maybe (Path Rel File) -> Sem r (Path Abs File)
- interpretPersist :: ToJSON a => FromJSON a => Members [PersistPath !! PersistPathError, Error BootError, Log, Embed IO] r => Text -> InterpreterFor (Persist a !! PersistError) r
- interpretPersistNull :: forall a err r. InterpreterFor (Persist a !! err) r
Documentation
persistBase :: Members [PersistPath !! PersistPathError, Stop PersistError] r => Sem r (Path Abs Dir) Source #
Obtain the root directory or stop.
loadFile :: FromJSON a => Members [Stop PersistError, Log, Embed IO] r => Path Abs File -> Sem r a Source #
Load a file and JSON-decode it.
filepath :: Members [PersistPath !! PersistPathError, Stop PersistError] r => Path Rel File -> Path Rel Dir -> Maybe (Path Rel File) -> Sem r (Path Abs File) Source #
Determine the path to use for a Persist
action.
If a subpath
is given, append it to dir
, otherwise use singleFile
.
Append the result of the first step to the root dir given by PersistPath
.
interpretPersist :: ToJSON a => FromJSON a => Members [PersistPath !! PersistPathError, Error BootError, Log, Embed IO] r => Text -> InterpreterFor (Persist a !! PersistError) r Source #
Interpret Persist
by writing to the file system.
Paths are determined as follows:
PersistPath
defines the root directory for allPersist
effects, which might be specific to a plugin, or additionally to entities like the currently edited project (e.g. by directory).- The value in the
name
argument is appended to the root depending on the arguments to the effect constructors. - When
store
orload
are invoked withNothing
for thesubpath
argument, a file namedname.json
is used. - When invoked with
Just
a subpath, a file namedname/subpath.json
is used.
interpretPersistNull :: forall a err r. InterpreterFor (Persist a !! err) r Source #
Interpret Persist
by storing nothing.