packages feed

PerfectHash 0.1.4 → 0.1.5

raw patch · 3 files changed

+26/−19 lines, 3 filesdep ~basePVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: base

API changes (from Hackage documentation)

- HackedMicrobench: instance [overlap ok] Microbenchable (IO ())
- HackedMicrobench: instance [overlap ok] Microbenchable (Integer -> IO ())
- HackedMicrobench: instance [overlap ok] Microbenchable (Integer -> a)
+ HackedMicrobench: instance HackedMicrobench.Microbenchable (GHC.Integer.Type.Integer -> GHC.Types.IO ())
+ HackedMicrobench: instance HackedMicrobench.Microbenchable (GHC.Integer.Type.Integer -> a)
+ HackedMicrobench: instance HackedMicrobench.Microbenchable (GHC.Types.IO ())
- Data.PerfectHash: fromList :: Show a => [(ByteString, a)] -> PerfectHash a
+ Data.PerfectHash: fromList :: (Show a) => [(ByteString, a)] -> PerfectHash a

Files

Data/PerfectHash.lhs view
@@ -1,15 +1,21 @@-> {-# LANGUAGE ForeignFunctionInterface, ScopedTypeVariables, EmptyDataDecls, BangPatterns, TypeSynonymInstances, FlexibleInstances #-}+> {-# LANGUAGE ForeignFunctionInterface #-}+> {-# LANGUAGE ScopedTypeVariables #-}+> {-# LANGUAGE EmptyDataDecls #-}+> {-# LANGUAGE BangPatterns #-}+> {-# LANGUAGE TypeSynonymInstances #-}+> {-# LANGUAGE FlexibleInstances #-}+> {-# LANGUAGE FlexibleContexts #-}  > module Data.PerfectHash ( PerfectHash, fromList, lookup, lookupByIndex ) where > > import Data.Array.Unsafe (unsafeFreeze) > import System.IO.Unsafe (unsafePerformIO) > import Data.Array-> import Data.Array.IO (newArray_,writeArray,IOArray)+> import Data.Array.IO (newArray, newArray_,writeArray,IOArray) > import Foreign(Ptr) > import Foreign.C.String > import Foreign.C.Types-> import Foreign.Marshal.Array+> import Foreign.Marshal.Array () > import Prelude hiding (lookup) > import qualified Data.ByteString.Char8 as S > import qualified Data.ByteString.Unsafe as Unsafe@@ -19,7 +25,8 @@ > import Data.Digest.Adler32 (adler32) > import Control.Monad(guard, liftM) > import GHC.Arr (unsafeAt)- +> import Data.Monoid+ Arguably the FFI stuff should be in a separate file, but let's keep it simple for the moment.  > foreign import ccall unsafe "cmph.h cmph_search" c_cmph_search :: Ptr ForeignHash -> CString -> CInt -> CULong@@ -67,7 +74,7 @@ This could do with being broken up a little, probably  -> fromList :: Show a => [(S.ByteString, a)] -> PerfectHash a+> fromList :: (Show a) => [(S.ByteString, a)] -> PerfectHash a > fromList ls = unsafePerformIO $ do >                   (fodder,cstr_ptrs) <- prepareCPtrs >                   cmph <- withStorableArray fodder $ \ptr -> c_build_hash ptr (fromIntegral len)@@ -87,7 +94,7 @@ >                   return (fodder, cstr_ptrs) > >         buildArray cmph cstr_ptrs = do->                   arr <- newArray_ (fromIntegral 0, fromIntegral len - 1) :: IO (IOArray Word32 a)+>                   arr <- (newArray_ (fromIntegral 0, fromIntegral len - 1) ) :: IO (IOArray Word32 a) >                   mapM_ (\(cl@(cstr,len),val) -> writeArray arr (raw_hashfunc cmph cl) (val,cstr)) $ cstr_ptrs >                   -- we created it, we can do what we like with it... >                   unsafeFreeze arr
HackedMicrobench.hs view
@@ -1,4 +1,5 @@-{-# LANGUAGE OverlappingInstances, FlexibleInstances #-}+{-# LANGUAGE FlexibleInstances    #-}+{-# LANGUAGE OverlappingInstances #-} -- microbench, a tiny microbenchmarking library for Haskell. -- Copyright (C) 2008 Evan Martin <martine@danga.com> --   hacked ever so slightly by mwotton@gmail.com in the interests@@ -39,15 +40,15 @@   Microbenchable ) where -import Control.Exception-import Debug.Trace-import Data.IORef-import Data.List-import Data.Time.Clock-import Data.Typeable-import Control.Concurrent-import System.IO-import Numeric+import           Control.Concurrent+import           Control.Exception+import           Data.IORef+import           Data.List+import           Data.Time.Clock+import           Data.Typeable+import           Debug.Trace+import           Numeric+import           System.IO  -- Want to handle: --   Int -> a    => ok@@ -102,4 +103,3 @@     if delta > microbenchTime       then do return (realToFrac delta / realToFrac repeats)       else probe (repeats * 2)-
PerfectHash.cabal view
@@ -1,5 +1,5 @@ Name:           PerfectHash-Version:        0.1.4+Version:        0.1.5 Cabal-Version:  >= 1.6 License:	BSD3 License-File:   LICENSE@@ -24,7 +24,7 @@         c-sources: stub.c         includes: stub.h         extra-libraries: cmph-        build-depends:  base >=4.5 && <4.8,+        build-depends:  base >=4.5 && <5.2,                         containers,                         bytestring,                         digest,