packages feed

nats 0.1.3 → 0.2

raw patch · 3 files changed

+69/−9 lines, 3 filesdep +hashable

Dependencies added: hashable

Files

CHANGELOG.markdown view
@@ -1,3 +1,13 @@+0.2+---+* Added `Hashable` and `Data` support.+* Will build as full-fledged `Safe` Haskell if you configure with -f-hashable, merely `Trustworthy` otherwise.+* Allow for manual removal of the `hashable` dependency to support advanced sandbox users who explicitly want to avoid compiling certain dependencies+  they know they aren't using.++  We will fix bugs caused by any combination of these package flags, but the API of the package should be considered the default build+  configuration with all of the package dependency flags enabled.+ 0.1.3 ----- * Added support for GHC 7.8's `bitSizeMaybe`
nats.cabal view
@@ -1,8 +1,8 @@ name:          nats category:      Numeric, Algebra-version:       0.1.3+version:       0.2 license:       BSD3-cabal-version: >= 1.8+cabal-version: >= 1.10 license-file:  LICENSE author:        Edward A. Kmett maintainer:    Edward A. Kmett <ekmett@gmail.com>@@ -25,15 +25,26 @@   type: git   location: git://github.com/ekmett/nats.git +flag hashable+  description:+    You can disable the use of the `hashable` package using `-f-hashable`.+    .+    Disabling this is an unsupported configuration, but it may be useful for accelerating builds in sandboxes for expert users.+    .+    If set we will not supply an instance of `Hashable`+  default: True+  manual: True+ library+  default-language: Haskell98   hs-source-dirs: src--  if !impl(hugs)-    cpp-options: -DLANGUAGE_DeriveDataTypeable--  build-depends: base >= 2 && < 10   ghc-options: -Wall    exposed-modules:     Numeric.Natural     Numeric.Natural.Internal++  build-depends: base >= 2 && < 10++  if flag(hashable)+    build-depends: hashable >= 1.1 && < 1.3
src/Numeric/Natural/Internal.hs view
@@ -1,11 +1,22 @@ {-# LANGUAGE CPP #-}-#ifdef LANGUAGE_DeriveDataTypeable++#ifdef __GLASGOW_HASKELL__+#define LANGUAGE_DeriveDataTypeable {-# LANGUAGE DeriveDataTypeable #-} #endif  #ifndef MIN_VERSION_base #define MIN_VERSION_base(x,y,z) 1 #endif++#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702+#ifdef MIN_VERSION_hashable+{-# LANGUAGE Trustworthy #-}+#else+{-# LANGUAGE Safe #-}+#endif+#endif+ ----------------------------------------------------------------------------- -- | -- Module      :  Numeric.Natural.Internal@@ -30,8 +41,11 @@ import Data.Bits import Data.Ix #ifdef LANGUAGE_DeriveDataTypeable-import Data.Typeable+import Data.Data #endif+#ifdef MIN_VERSION_hashable+import Data.Hashable+#endif  newtype Natural = Natural { runNatural :: Integer } deriving   ( Eq@@ -41,6 +55,31 @@   , Typeable #endif   )++#ifdef MIN_VERSION_hashable+instance Hashable Natural where+#if MIN_VERSION_hashable(1,2,0)+  hashWithSalt p (Natural a) = hashWithSalt p a+#else+  hash (Natural a) = hash a+#endif+#endif++#ifdef LANGUAGE_DeriveDataTypeable+instance Data Natural where+  gfoldl f z (Natural n) = z fromInteger `f` n+  gunfold k z c = case constrIndex c of+    1 -> k (z fromInteger)+    _ -> error "Natural: gunfold: bad constructor"+  toConstr _     = fromIntegerConstr+  dataTypeOf _   = naturalDataType++fromIntegerConstr :: Constr+fromIntegerConstr = mkConstr naturalDataType "fromInteger" [] Prefix++naturalDataType :: DataType+naturalDataType = mkDataType "Numeric.Natural.Internal.Natural" [fromIntegerConstr]+#endif  -- | Church decoding natural :: a -> (a -> a) -> Natural -> a