-- This file has been generated from package.yaml by hpack version 0.20.0. -- -- see: https://github.com/sol/hpack -- -- hash: 5294c49846f25b6cb06c72295e7bffbdf2443d5e99a7f79652dd5176510b48b5 name: perfect-hash-generator version: 0.2.0.6 synopsis: Perfect minimal hashing implementation in native Haskell description: A for a set @S@ is a hash function that maps distinct elements in @S@ to a set of integers, with __no collisions__. A is a perfect hash function that maps @n@ keys to @n@ __consecutive__ integers, e.g. the numbers from @0@ to @n-1@. . In contrast with the , which is a binding to a C-based library, this package is a fully-native Haskell implementation. . It is intended primarily for generating C code for embedded applications (compare to @@). The output of this tool is a pair of arrays that can be included in generated C code for __ hash tables__. . Though lookups also perform reasonably well for Haskell applications, it hasn't been benchmarked thorougly with respect to other data structures. . This implementation was adapted from . . = Usage The library is written generically to hash both strings and raw integers according to the . Integers are split by octets before hashing. . > import Data.PerfectHash.Construction (createMinimalPerfectHash) > import qualified Data.HashMap.Strict as HashMap > > tuples = [ > (1000, 1) > , (5555, 2) > , (9876, 3) > ] > > lookup_table = createMinimalPerfectHash $ HashMap.fromList tuples . Generation of C code based on the arrays in @lookup_table@ is left as an exercise to the reader. Algorithm documentation in the "Data.PerfectHash.Hashing" and "Data.PerfectHash.Lookup" modules will be helpful. . See the @hash-perfectly-strings-demo@ and @hash-perfectly-ints-demo@, as well as the test suite, for working examples. . > $ stack build > $ stack exec hash-perfectly-strings-demo category: Data Structures, Embedded homepage: https://github.com/kostmo/perfect-hash-generator#readme bug-reports: https://github.com/kostmo/perfect-hash-generator/issues author: Karl Ostmo maintainer: Karl Ostmo license: Apache-2.0 license-file: LICENSE build-type: Simple cabal-version: >= 1.10 source-repository head type: git location: https://github.com/kostmo/perfect-hash-generator library hs-source-dirs: src ghc-options: -fwarn-tabs -W build-depends: base >=4.5 && <5 , binary , bytestring , containers , data-ordlist , directory , filepath , hashable , text , unordered-containers , vector exposed-modules: Data.PerfectHash.Construction Data.PerfectHash.Hashing Data.PerfectHash.Lookup other-modules: Paths_perfect_hash_generator default-language: Haskell2010 executable hash-perfectly-ints-demo main-is: Main.hs hs-source-dirs: demo/ints test-utils ghc-options: -fwarn-tabs -W build-depends: base >=4.5 && <5 , binary , bytestring , containers , hashable , optparse-applicative , perfect-hash-generator , random , text , unordered-containers , vector other-modules: Exercise Paths_perfect_hash_generator default-language: Haskell2010 executable hash-perfectly-strings-demo main-is: Main.hs hs-source-dirs: demo/strings test-utils ghc-options: -fwarn-tabs -W build-depends: base >=4.5 && <5 , binary , bytestring , hashable , optparse-applicative , perfect-hash-generator , random , text , unordered-containers , vector other-modules: Exercise Paths_perfect_hash_generator default-language: Haskell2010 test-suite regression-tests type: exitcode-stdio-1.0 main-is: Main.hs hs-source-dirs: test test-utils ghc-options: -fwarn-tabs -W build-depends: HUnit , base >=4.5 && <5 , binary , bytestring , hashable , optparse-applicative , perfect-hash-generator , test-framework , test-framework-hunit , text , unordered-containers , vector other-modules: Exercise Paths_perfect_hash_generator default-language: Haskell2010