Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NFData instance for ByteArray #65

Merged
merged 1 commit into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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