deepseq-generics 0.1.0.0 → 0.1.1.0
raw patch · 3 files changed
+76/−9 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Control.DeepSeq.Generics: genericRnfV1 :: (Generic a, GNFDataV1 (Rep a)) => a -> ()
+ Control.DeepSeq.Generics: instance (GNFDataV1 a, GNFDataV1 b) => GNFDataV1 (a :*: b)
+ Control.DeepSeq.Generics: instance (GNFDataV1 a, GNFDataV1 b) => GNFDataV1 (a :+: b)
+ Control.DeepSeq.Generics: instance GNFDataV1 U1
+ Control.DeepSeq.Generics: instance GNFDataV1 V1
+ Control.DeepSeq.Generics: instance GNFDataV1 a => GNFDataV1 (M1 i c a)
+ Control.DeepSeq.Generics: instance NFData a => GNFDataV1 (K1 i a)
Files
- Control/DeepSeq/Generics.hs +59/−3
- changelog +9/−0
- deepseq-generics.cabal +8/−6
Control/DeepSeq/Generics.hs view
@@ -17,6 +17,7 @@ module Control.DeepSeq.Generics ( genericRnf+ , genericRnfV1 -- * "Control.DeepSeq" re-exports , deepseq , force@@ -76,12 +77,13 @@ {-# INLINE genericRnf #-} -- | Hidden internal type-class+--+-- Note: the 'V1' instance is not provided for 'GNFData' in order to+-- trigger a compile-time error; see 'GNFDataV1' which defers this to+-- a runtime error. class GNFData f where grnf_ :: f a -> () --- note: the V1 instance is not provided, as uninhabited types can't--- be reduced to NF anyway- instance GNFData U1 where grnf_ !U1 = () {-# INLINE grnf_ #-}@@ -102,3 +104,57 @@ grnf_ (L1 x) = grnf_ x grnf_ (R1 x) = grnf_ x {-# INLINE grnf_ #-}+++-- | Variant of 'genericRnf' which supports derivation for uninhabited types.+--+-- For instance, the type+--+-- > data TagFoo deriving Generic+--+-- would cause a compile-time error with 'genericRnf', but with+-- 'genericRnfV1' the error is deferred to run-time:+--+-- > Prelude> genericRnf (undefined :: TagFoo)+-- >+-- > <interactive>:1:1:+-- > No instance for (GNFData V1) arising from a use of `genericRnf'+-- > Possible fix: add an instance declaration for (GNFData V1)+-- > In the expression: genericRnf (undefined :: TagFoo)+-- > In an equation for `it': it = genericRnf (undefined :: TagFoo)+-- >+-- > Prelude> genericRnfV1 (undefined :: TagFoo)+-- > *** Exception: Control.DeepSeq.Generics.genericRnfV1: NF not defined for uninhabited types+--+-- /Since: 0.1.1.0/+genericRnfV1 :: (Generic a, GNFDataV1 (Rep a)) => a -> ()+genericRnfV1 = grnfV1_ . from+{-# INLINE genericRnfV1 #-}++-- | Variant of 'GNFData' supporting 'V1'+class GNFDataV1 f where+ grnfV1_ :: f a -> ()++instance GNFDataV1 V1 where+ grnfV1_ = error "Control.DeepSeq.Generics.genericRnfV1: NF not defined for uninhabited types"++instance GNFDataV1 U1 where+ grnfV1_ !U1 = ()+ {-# INLINE grnfV1_ #-}++instance NFData a => GNFDataV1 (K1 i a) where+ grnfV1_ = rnf . unK1+ {-# INLINE grnfV1_ #-}++instance GNFDataV1 a => GNFDataV1 (M1 i c a) where+ grnfV1_ = grnfV1_ . unM1+ {-# INLINE grnfV1_ #-}++instance (GNFDataV1 a, GNFDataV1 b) => GNFDataV1 (a :*: b) where+ grnfV1_ (x :*: y) = grnfV1_ x `seq` grnfV1_ y+ {-# INLINE grnfV1_ #-}++instance (GNFDataV1 a, GNFDataV1 b) => GNFDataV1 (a :+: b) where+ grnfV1_ (L1 x) = grnfV1_ x+ grnfV1_ (R1 x) = grnfV1_ x+ {-# INLINE grnfV1_ #-}
+ changelog view
@@ -0,0 +1,9 @@+-*-change-log-*-++0.1.1.0 Herbert Valerio Riedel <hvr@gnu.org> September 2013++ * Control/DeepSeq/Generics.hs (genericRnfV1): New Function++0.1.0.0 Herbert Valerio Riedel <hvr@gnu.org> September 2012++ * Initial Release
deepseq-generics.cabal view
@@ -1,8 +1,8 @@--- Initial deepseq-generics.cabal generated by cabal init. For further +-- Initial deepseq-generics.cabal generated by cabal init. For further -- documentation, see http://haskell.org/cabal/users-guide/ name: deepseq-generics-version: 0.1.0.0+version: 0.1.1.0 synopsis: GHC.Generics-based Control.DeepSeq.rnf implementation homepage: https://github.com/hvr/deepseq-generics license: BSD3@@ -14,7 +14,7 @@ build-type: Simple cabal-version: >=1.10 tested-with: GHC >=7.4.1-description: +description: This package provides a "GHC.Generics"-based 'Control.DeepSeq.Generics.genericRnf' function which can be used for providing a 'rnf' implementation. See the documentation for@@ -23,12 +23,14 @@ . The original idea was pioneered in the @generic-deepseq@ package (see <http://www.haskell.org/pipermail/haskell-cafe/2012-February/099551.html>- for more information). + for more information). . This package differs from the @generic-deepseq@ package by working in combination with the existing @deepseq@ package as opposed to defining a conflicting drop-in replacement for @deepseq@'s @Control.Deepseq@ module. +extra-source-files: changelog+ source-repository head type: git location: https://github.com/hvr/deepseq-generics.git@@ -40,7 +42,7 @@ other-extensions: BangPatterns, TypeOperators, FlexibleContexts ghc-options: -Wall -test-suite tests+test-suite deepseq-generics-tests default-language: Haskell2010 type: exitcode-stdio-1.0 main-is: Suite.hs@@ -54,7 +56,7 @@ deepseq-generics, ghc-prim, -- end of packages with inherited version constraints- test-framework, + test-framework, test-framework-hunit, HUnit