No description, website, or topics provided.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bench
examples/simple-app
mem-test
src
test
.gitignore
Changelog.md
LICENSE
README.md
jenkins.sh
simple-store.cabal
stack.yaml

README.md

simple-store

Often in haskell you have a shared data type that needs persistence, atomicity and consistency.

Usage

The core datatype for SimpleStore is

data SimpleStore st = SimpleStore {
    storeFP     :: FilePath
  , storeState  :: TVar st
  , storeLock   :: TMVar StoreLock
  , storeHandle :: Maybe Handle
}

Say your Datatype is :

data Address = Address { street :: Street , town::Town}
  deriving (Generic,Eq,Ord)

instance Serialize Address where 


``` haskell


You might write:

``` haskell
-- | makeSimpleStore :: FilePath -> st -> IO (Either StoreError (SimpleStore st))

djangosAddress = do
   eSt(makeSimpleStore "DjangoAddress" (Address MinorSwingBlvd GypsyTown))
   either (\e -> fail (show e) ) (return st)  eSt

A directory containing a serialized version of Django's address is saved for you Note you can use text serialization too so it is readable.

Now you can share that between processes (in a Yesod for instance)

lets walk there

walkToDjangosHouse :: IO () 
walkToDjangosHouse = do
  djAddr <- getSimpleStore djangosAddress
  walkToDjangosHouse djAddr