module Ribosome.Effect.Persist where
import Path (File, Path, Rel)
data Persist a :: Effect where
Store :: Maybe (Path Rel File) -> a -> Persist a m ()
Load :: Maybe (Path Rel File) -> Persist a m (Maybe a)
makeSem_ ''Persist
store ::
∀ a r .
Member (Persist a) r =>
Maybe (Path Rel File) ->
a ->
Sem r ()
load ::
∀ 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
loadOr :: forall a (r :: EffectRow).
Member (Persist a) r =>
Maybe (Path Rel File) -> a -> Sem r a
loadOr Maybe (Path Rel File)
path a
a =
a -> Maybe a -> a
forall a. a -> Maybe a -> a
fromMaybe a
a (Maybe a -> a) -> Sem r (Maybe a) -> Sem r a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (Path Rel File) -> Sem r (Maybe a)
forall a (r :: EffectRow).
Member (Persist a) r =>
Maybe (Path Rel File) -> Sem r (Maybe a)
load Maybe (Path Rel File)
path
loadSingle ::
Member (Persist a) r =>
Sem r (Maybe a)
loadSingle :: forall a (r :: EffectRow). Member (Persist a) r => Sem r (Maybe a)
loadSingle =
Maybe (Path Rel File) -> Sem r (Maybe a)
forall a (r :: EffectRow).
Member (Persist a) r =>
Maybe (Path Rel File) -> Sem r (Maybe a)
load Maybe (Path Rel File)
forall a. Maybe a
Nothing
loadSingleOr ::
Member (Persist a) r =>
a ->
Sem r a
loadSingleOr :: forall a (r :: EffectRow). Member (Persist a) r => a -> Sem r a
loadSingleOr a
a =
a -> Maybe a -> a
forall a. a -> Maybe a -> a
fromMaybe a
a (Maybe a -> a) -> Sem r (Maybe a) -> Sem r a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Sem r (Maybe a)
forall a (r :: EffectRow). Member (Persist a) r => Sem r (Maybe a)
loadSingle
loadPath ::
Member (Persist a) r =>
Path Rel File ->
Sem r (Maybe a)
loadPath :: forall a (r :: EffectRow).
Member (Persist a) r =>
Path Rel File -> Sem r (Maybe a)
loadPath Path Rel File
path =
Maybe (Path Rel File) -> Sem r (Maybe a)
forall a (r :: EffectRow).
Member (Persist a) r =>
Maybe (Path Rel File) -> Sem r (Maybe a)
load (Path Rel File -> Maybe (Path Rel File)
forall a. a -> Maybe a
Just Path Rel File
path)
loadPathOr ::
Member (Persist a) r =>
Path Rel File ->
a ->
Sem r a
loadPathOr :: forall a (r :: EffectRow).
Member (Persist a) r =>
Path Rel File -> a -> Sem r a
loadPathOr Path Rel File
path a
a =
a -> Maybe a -> a
forall a. a -> Maybe a -> a
fromMaybe a
a (Maybe a -> a) -> Sem r (Maybe a) -> Sem r a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Path Rel File -> Sem r (Maybe a)
forall a (r :: EffectRow).
Member (Persist a) r =>
Path Rel File -> Sem r (Maybe a)
loadPath Path Rel File
path