Module
Data.Storage
- Package
- purescript-storable
- Repository
- GoNZooo/purescript-storable
#MonadStorage Source
class (Storable a) <= MonadStorage m a whereMembers
store :: a -> m (Either StorageError Unit)retrieve :: String -> m (Either StorageError a)Reads a storable
awhen given a key in monadm, returning either aLeftcontaining an error representing unavailable storage, decoding error or no value matching the supplied' key.
Instances
(Storable a) => MonadStorage LocalStorage a(Storable a) => MonadStorage SessionStorage a(Storable a, MonadState (Map String String) m) => MonadStorage m a
#Storable Source
class Storable a whereMembers
key :: a -> StringProduces a key from the given
a. This is most appropriately anidor something like it.prefix :: Proxy a -> StringWhen given a proxy of
areturns a prefix that all items with that type will be stored with.serialize :: a -> StringTakes an
aand (hopefully) reliably turns it into a string; this should be symmetric withdeserialize. This can be conveniently implemented usingSimple.JSON.deserialize :: String -> Either StorageError aTakes a string and either successfully decodes it into a
Right aor returns aDecodingErrorthat contains aNonEmptyList ForeignError. This matches the error value thatSimple.JSONreturns.
Writes a storable
ain a monadm, returningLeft NoStorageErrorrepresenting the lack of a storage on error or returningRight Uniton success.