packages feed

DimensionalHash 0.1.5 → 0.1.5.1

raw patch · 2 files changed

+24/−10 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Data/DimensionalHash.hs view
@@ -1,6 +1,14 @@---
--- Morton number generator
--- Can be used for n-dimensional hash
+-----------------------------------------------------------------------------
+-- |
+-- Module      : Data.DimensionalHash
+-- Copyright   : Hamrouni Ghassen
+-- License     : BSD3
+-- 
+-- Maintainer  : Hamrouni Ghassen <ghamrouni@iptechinside.com>
+-- Stability   :
+-- Portability :
+--
+-----------------------------------------------------------------------------
 
 module Data.DimensionalHash  
 (
@@ -11,17 +19,18 @@ import Data.Int
 import Data.Word
 
-import Control.Exception
-import Data.Typeable
-
 ------------------------------------------------------------------------
 
 class (Bits a, Integral a) => (MortonNumber a) where
 	-- | recursevely compute the morton number.	
 	dimensionalHash :: (Bits a) => [a] -> a
 	dimensionalHash [] 		= 0
-	dimensionalHash list 	= hash list 0 (bitSize (head list))
-	
+	dimensionalHash list
+		| hachable == True = hash list 0 (bitSize (head list))
+		| otherwise = error "The list is not hashable."
+		where
+			hachable = isHashable list
+ 	
 	-- | compute max bit size for the element of the list
 	maxBitSize :: (Bits a) => [a] -> Int
 	maxBitSize list = div (bitSize (head list)) (length list)
@@ -44,7 +53,12 @@ 			
 -- Integer haven't a fixed bitsize
 instance MortonNumber Integer where
-	dimensionalHash list = hash list 0 32
+	dimensionalHash list
+		| hachable == True = hash list 0 32
+		| otherwise = error "The list is not hashable."
+		where
+			hachable = isHashable list
+	
 	maxBitSize list = div 32 (length list)
 
 -- Types that have a fixed bitsize are instance of MortonNumber
DimensionalHash.cabal view
@@ -1,5 +1,5 @@ name:          DimensionalHash
-version:       0.1.5
+version:       0.1.5.1
 build-Type:    Simple
 cabal-version: >= 1.6
 tested-with:   GHC == 7.0.3