Skip to content

Commit

Permalink
Merge pull request #65 from Bodigrim/master
Browse files Browse the repository at this point in the history
Add NFData instance for ByteArray
  • Loading branch information
mixphix authored Dec 2, 2021
2 parents 895aa07 + 7336f01 commit 058fee3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Control/DeepSeq.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
{-# OPTIONS_GHC -Wno-deprecations #-}
#endif

#define BYTEARRAY_IN_BASE (__GLASGOW_HASKELL__ >= 903)
-- At the moment of writing GHC source tree has not yet bumped `base` version,
-- so using __GLASGOW_HASKELL__ as a proxy instead of MIN_VERSION_base(4,17,0).

-----------------------------------------------------------------------------
-- |
-- Module : Control.DeepSeq
Expand Down Expand Up @@ -161,6 +165,10 @@ import GHC.Tuple (Solo (..))
#endif
#endif

#if BYTEARRAY_IN_BASE
import Data.Array.Byte (ByteArray(..))
#endif

-- | Hidden internal type-class
class GNFData arity f where
grnf :: RnfArgs arity a -> f a -> ()
Expand Down Expand Up @@ -1046,3 +1054,12 @@ instance (NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6, NFDa
instance (NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6, NFData a7) =>
NFData2 ((,,,,,,,,) a1 a2 a3 a4 a5 a6 a7) where
liftRnf2 r r' (x1,x2,x3,x4,x5,x6,x7,x8,x9) = rnf x1 `seq` rnf x2 `seq` rnf x3 `seq` rnf x4 `seq` rnf x5 `seq` rnf x6 `seq` rnf x7 `seq` r x8 `seq` r' x9

----------------------------------------------------------------------------
-- ByteArray

#if BYTEARRAY_IN_BASE
-- |@since 1.4.6.0
instance NFData ByteArray where
rnf (ByteArray _) = ()
#endif
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
([#69](https://github.com/haskell/deepseq/pull/69))
* Add once again `infixr 0 deepseq`
([#56](https://github.com/haskell/deepseq/pull/56), [#74](https://github.com/haskell/deepseq/issues/74))
* Add `NFData` instance for `ByteArray`
([#65](https://github.com/haskell/deepseq/pull/65))

## 1.4.6.1

Expand Down

0 comments on commit 058fee3

Please sign in to comment.