[commit: packages/deepseq] master, typeable-with-kinds: Extend `rnf` documentation to mention GHC 7.10's `DeriveAnyClass` extension (7618263)
git at git.haskell.org
git at git.haskell.org
Thu Mar 19 11:35:31 UTC 2015
Repository : ssh://git@git.haskell.org/deepseq
On branches: master,typeable-with-kinds
Link : http://git.haskell.org/packages/deepseq.git/commitdiff/7618263f57988c81117d3d1703409bf592b15398
>---------------------------------------------------------------
commit 7618263f57988c81117d3d1703409bf592b15398
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date: Sun Nov 23 17:39:39 2014 +0100
Extend `rnf` documentation to mention GHC 7.10's `DeriveAnyClass` extension
>---------------------------------------------------------------
7618263f57988c81117d3d1703409bf592b15398
Control/DeepSeq.hs | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/Control/DeepSeq.hs b/Control/DeepSeq.hs
index c6fc69d..7ab8257 100644
--- a/Control/DeepSeq.hs
+++ b/Control/DeepSeq.hs
@@ -159,6 +159,8 @@ class NFData a where
-- | 'rnf' should reduce its argument to normal form (that is, fully
-- evaluate all sub-components), and then return '()'.
--
+ -- === 'Generic' 'NFData' deriving
+ --
-- Starting with GHC 7.2, you can automatically derive instances
-- for types possessing a 'Generic' instance.
--
@@ -177,9 +179,29 @@ class NFData a where
-- >
-- > instance NFData Colour
--
- -- __Compatibility Note__: Prior to version 1.4.0, the default
- -- implementation of 'rnf' was \"@'rnf' a = 'seq' a ()@\",
- -- however, starting with @deepseq-1.4.0.0@, the default
+ -- Starting with GHC 7.10, the example above can be written more
+ -- concisely by enabling the new @DeriveAnyClass@ extension:
+ --
+ -- > {-# LANGUAGE DeriveGeneric, DeriveAnyClass #-}
+ -- >
+ -- > import GHC.Generics (Generic)
+ -- > import Control.DeepSeq
+ -- >
+ -- > data Foo a = Foo a String
+ -- > deriving (Eq, Generic, NFData)
+ -- >
+ -- > data Colour = Red | Green | Blue
+ -- > deriving (Generic, NFData)
+ -- >
+ --
+ -- === Compatibility with previous @deepseq@ versions
+ --
+ -- Prior to version 1.4.0, the default implementation of the 'rnf'
+ -- method was defined as
+ --
+ -- @'rnf' a = 'seq' a ()@
+ --
+ -- However, starting with @deepseq-1.4.0.0@, the default
-- implementation is based on @DefaultSignatures@ allowing for
-- more accurate auto-derived 'NFData' instances. If you need the
-- previously used exact default 'rnf' method implementation
More information about the ghc-commits
mailing list