-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | acid-state snaplet for Snap Framework
--   
--   This snaplet makes it easy to use acid-state in a Snap application.
@package snaplet-acid-state
@version 0.2.6.1

module Snap.Snaplet.AcidState

-- | Data type holding acid-state snaplet data.
newtype Acid st
Acid :: AcidState st -> Acid st
_acidStore :: Acid st -> AcidState st

-- | Type class standardizing a context that holds an AcidState.
--   
--   You can minimize boilerplate in your application by adding an instance
--   like the following:
--   
--   <pre>
--   data App = App { ... _acid :: Snaplet (Acid MyState) ... }
--   instance HasAcid App MyState where
--       getAcidStore = getL (snapletValue . acid)
--   </pre>
class HasAcid myState acidState | myState -> acidState
getAcidStore :: HasAcid myState acidState => myState -> (Acid acidState)

-- | Initializer that stores the state in the "state/[typeOf state]/"
--   directory.
acidInit :: (IsAcidic st, Typeable st) => st -> SnapletInit b (Acid st)

-- | Initializer allowing you to specify the location of the acid-state
--   store.
acidInit' :: IsAcidic st => FilePath -> st -> SnapletInit b (Acid st)

-- | Initializer allowing you to open an in-memory store (typically for
--   testing)
acidInitMemory :: IsAcidic st => st -> SnapletInit b (Acid st)

-- | Initializer allowing you to specify the AcidState to use. This
--   AcidState must be initialized manually elsewhere. It will not be
--   automatically closed by the snaplet.
acidInitManual :: IsAcidic st => AcidState st -> SnapletInit b (Acid st)

-- | Lower-level function providing direct access to the AcidState data
--   type.
getAcidState :: (HasAcid s st, MonadSnaplet m, MonadState s (m b b)) => m b v (AcidState st)

-- | Wrapper for acid-state's update function that works for arbitrary
--   instances of HasAcid.
update :: (HasAcid s (MethodState event), MonadSnaplet m, MonadState s (m b b), UpdateEvent event, MonadIO (m b v)) => event -> m b v (EventResult event)

-- | Wrapper for acid-state's query function that works for arbitrary
--   instances of HasAcid.
query :: (HasAcid s (MethodState event), MonadSnaplet m, MonadState s (m b b), QueryEvent event, MonadIO (m b v)) => event -> m b v (EventResult event)

-- | Wrapper for acid-state's createCheckpoint function that works for
--   arbitrary instances of HasAcid.
createCheckpoint :: (MonadIO (m b v), MonadSnaplet m, MonadState s (m b b), HasAcid s st) => m b v ()

-- | Wrapper for acid-state's closeAcidState function that works for
--   arbitrary instances of HasAcid. The state is automatically closed by
--   the snaplet's unload action, but this is here in case the user needs
--   more control.
closeAcidState :: (MonadIO (m b v), MonadSnaplet m, MonadState s (m b b), HasAcid s st) => m b v ()

-- | Core init functionality common to both exported variants.
initWorker :: IO (AcidState st) -> Initializer b v (Acid st)
instance HasAcid (Acid st) st
