JunkDB-driver-hashtables (empty) → 0.1.0.0
raw patch · 4 files changed
+102/−0 lines, 4 filesdep +JunkDBdep +basedep +bytestringsetup-changed
Dependencies added: JunkDB, base, bytestring, conduit, hashable, hashtables, mtl, resourcet
Files
- Database/Junk/HashTable.hs +22/−0
- JunkDB-driver-hashtables.cabal +48/−0
- LICENSE +30/−0
- Setup.hs +2/−0
+ Database/Junk/HashTable.hs view
@@ -0,0 +1,22 @@+{-# LANGUAGE TypeFamilies, RankNTypes,TypeSynonymInstances, MultiParamTypeClasses,FlexibleInstances #-}+module Database.Junk.HashTable (HT (..)) where++import Control.Monad.Trans (lift)+import qualified Data.Hashable as HS (Hashable)+import qualified Data.HashTable.Class as H (HashTable)+import qualified Data.HashTable.IO as H+import Data.Conduit (yield, ($=))+import qualified Data.Conduit.List as C (concatMapM)++import Database.KVS++newtype HT h k v = HT { unHT :: H.IOHashTable h k v }++instance (Eq k, H.HashTable h, HS.Hashable k) => KVS (HT h k v) IO k v where+ insert = H.insert . unHT+ accept c k f g = H.lookup (unHT c) k >>= maybe f g+ delete (HT ht) k = H.delete ht k >> return Nothing++instance (Eq k, H.HashTable h, HS.Hashable k) => EnumeratableKVS (HT h k v) IO k v where+ elemsWithKey (HT c) = yield c $= C.concatMapM (lift . H.toList)+
+ JunkDB-driver-hashtables.cabal view
@@ -0,0 +1,48 @@+-- Initial JunkDB.cabal generated by cabal init. For further +-- documentation, see http://haskell.org/cabal/users-guide/++name: JunkDB-driver-hashtables+version: 0.1.0.0+-- synopsis: +description: Generic KVS API+license: BSD3+license-file: LICENSE+author: HATTORI, Hiroki+maintainer: seagull.kamome@gmail.com+-- copyright: +category: Database+build-type: Simple+cabal-version: >=1.8++source-repository head+ type: git+ location: https://github.com/seagull-kamome/JunkDB++library+ exposed-modules: Database.Junk.HashTable+ ghc-options: -Wall+ build-depends: base ==4.6.*,+ JunkDB ==0.1.*,+ mtl ==2.1.*,+ bytestring ==0.10.*,+ conduit ==1.0.*,+ hashable >=1.1.2.0,+ hashtables ==1.1.*,+ resourcet ==0.4.*++-- test-suite spec+-- type: exitcode-stdio-1.0+-- ghc-options: -Wall -lgdbm+-- hs-source-dirs: test/+-- main-is: test.hs+-- build-depends: base,+-- mtl ==2.1.*,+-- directory ==1.2.*,+-- text,+-- hspec,+-- JunkDB,+-- hashable ==1.2.*,+-- hashtables ==1.1.*,+-- resourcet ==0.4.*,+-- conduit ==1.0.*,+-- HUnit ==1.2.*
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2013, HATTORI, Hiroki++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of HATTORI, Hiroki nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain