View on GitHub
File Changes
{-# LANGUAGE DataKinds #-}
+
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}

                      

                      
import Cardano.Wallet.Primitive.Types
    ( BlockHeader, EpochNo (..), PoolId, SlotId (..) )
+
import Control.Monad.Fail
+
    ( MonadFail )
import Control.Monad.Trans.Except
    ( ExceptT )
-
import Control.Monad.Fail (MonadFail)
import Data.Map.Strict
    ( Map )
import Data.Quantity
    ( Word64 )

                      
-- | A Database interface for storing pool production in DB.
+
--
+
-- To use it, you will need the NamedFieldPuns extension and wrap operations
+
-- with @[email protected]:
+
--
+
-- Example:
+
-- >>> :set -XNamedFieldPuns
+
-- >>> DBLayer{atomically,putPoolProduction} = db
+
-- >>> atomically $ putPoolProduction blockHeader pool
+
--
+
-- This gives you the power to also run /multiple/ operations atomically.
data DBLayer m2 = forall m. MonadFail m => DBLayer
    { putPoolProduction
        :: BlockHeader
        -- ^ Clean a database
    , atomically
        :: forall a. m a -> m2 a
+
        -- ^ Run an operation.
+
        --
+
        -- For a Sqlite DB, this would be "run a query inside a transaction".
    }

                      
-- | Forbidden operation was executed on an already existing slot