packages feed

higher-leveldb 0.2.0.0 → 0.2.1.0

raw patch · 2 files changed

+39/−27 lines, 2 filesdep ~bytestringdep ~cerealdep ~data-default

Dependency ranges changed: bytestring, cereal, data-default, lifted-base, monad-control, mtl, transformers, transformers-base

Files

higher-leveldb.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                higher-leveldb-version:             0.2.0.0+version:             0.2.1.0 synopsis:            A rich monadic API for working with leveldb databases. description:         A rich monadic API for working with leveldb databases. homepage:            https://github.com/jeremyjh/higher-leveldb@@ -15,6 +15,10 @@ build-type:          Simple cabal-version:       >=1.8 +source-repository head+  type:     git+  location: git://github.com/jeremyjh/higher-leveldb.git+ library    ghc-options:         -Wall@@ -22,16 +26,16 @@   -- other-modules:          hs-source-dirs:      src   build-depends:       base == 4.* -                       , cereal -                       , lifted-base+                       , cereal  >= 0.4 && < 0.5+                       , lifted-base >= 0.2.1.1 && < 0.3                        , leveldb-haskell >= 0.2 && <= 0.7-                       , bytestring+                       , bytestring >= 0.10 && < 0.11                        , resourcet       >=  1.1.0 && <= 1.2-                       , transformers-base-                       , mtl-                       , monad-control-                       , data-default-                       , transformers+                       , transformers-base >= 0.4.1 && < 0.5+                       , mtl >= 2.0 && < 2.2+                       , monad-control >= 0.3 && < 1.1+                       , data-default >= 0.5.1 && < 0.6+                       , transformers >= 0.3 && < 0.5   test-suite spec
src/Database/LevelDB/Higher.hs view
@@ -17,6 +17,7 @@ {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE ConstraintKinds #-}+{-# LANGUAGE RecordWildCards #-}  module Database.LevelDB.Higher     (@@ -143,8 +144,21 @@ instance (MonadResourceBase m) => MonadResource (LevelDBT m) where     liftResourceT = LevelDBT . liftResourceT --- TODO: figure out what this does+#if MIN_VERSION_monad_control(1,0,0) instance MonadTransControl LevelDBT where+    type StT LevelDBT a = StT ResourceT (StT (ReaderT DBContext) a)+    liftWith f =+            LevelDBT $ liftWith $ \run ->+                       liftWith $ \run' ->+                       f $ run' . run . unLevelDBT+    restoreT = LevelDBT . restoreT . restoreT++instance (MonadBaseControl b m) => MonadBaseControl b (LevelDBT m) where+    type StM (LevelDBT m) a =  ComposeSt LevelDBT m a+    liftBaseWith = defaultLiftBaseWith+    restoreM     = defaultRestoreM+#else+instance MonadTransControl LevelDBT where     newtype StT LevelDBT a = StLevelDBT             {unStLevelDBT :: StT ResourceT (StT (ReaderT DBContext) a) }     liftWith f =@@ -157,6 +171,7 @@     newtype StM (LevelDBT m) a =  StMT {unStMT :: ComposeSt LevelDBT m a}     liftBaseWith = defaultLiftBaseWith StMT     restoreM     = defaultRestoreM unStMT+#endif  -- | MonadLevelDB class used by all the public functions in this module. class ( Monad m@@ -238,7 +253,7 @@            -> KeySpace -- ^ "Bucket" in which Keys will be unique            -> LevelDBT m a -- ^ The actions to execute            -> m a-runCreateLevelDB path ks ma = runLevelDB path def{createIfMissing=True} def ks ma+runCreateLevelDB path = runLevelDB path def{createIfMissing=True} def   -- | Fork a LevelDBT IO action and return ThreadId into the current monad.@@ -248,9 +263,7 @@               => LevelDB ()               -> m ThreadId forkLevelDB ma = liftLevelDB $ LevelDBT $-    mapReaderT-        (\rt -> resourceForkIO rt) $-        unLevelDBT ma+    mapReaderT resourceForkIO (unLevelDBT ma)  -- | Use a local keyspace for the operation. e.g.: --@@ -344,39 +357,34 @@      => Key  -- ^ Key at which to start the scan.      -> ScanQuery a b -- ^ query functions to execute -- see 'ScanQuery' docs.      -> m b-scan k scanQuery = do+scan k ScanQuery{..} = do     (db, ksId, (ropt,_)) <- getDB     withIterator db ropt $ doScan (ksId <> k) ksId   where     doScan prefix ksId iter = do         iterSeek iter prefix-        applyIterate initV+        applyIterate scanInit       where         readItem = do             nk <- iterKey iter             nv <- iterValue iter-            if sameKsId nk then-                return (fmap (BS.drop 4) nk, nv) --unkeyspace-                else return (Nothing, Nothing)+            return $+                if sameKsId nk then (fmap (BS.drop 4) nk, nv) --unkeyspace+                else (Nothing, Nothing)         applyIterate acc = do             item <- readItem             case item of                 (Just nk, Just nv) ->-                    if whileFn (nk, nv) acc then do+                    if scanWhile k (nk, nv) acc then do                         iterNext iter                         items <- applyIterate acc-                        return $ if filterFn (nk, nv) then-                                     reduceFn (mapFn (nk, nv)) items+                        return $ if scanFilter (nk, nv) then+                                     scanFold (scanMap (nk, nv)) items                                  else items                     else return acc                 _ -> return acc         sameKsId Nothing = False         sameKsId (Just nk) = BS.take 4 nk == ksId-    initV = scanInit scanQuery-    whileFn = scanWhile scanQuery k-    mapFn = scanMap scanQuery-    filterFn = scanFilter scanQuery-    reduceFn = scanFold scanQuery  -- | Structure containing functions used within the 'scan' function. You may want to start -- with one of the builder/helper funcions such as 'queryItems', which is defined as: