Skip to content

Commit 058fee3

Browse files
authored
Merge pull request #65 from Bodigrim/master
Add NFData instance for ByteArray
2 parents 895aa07 + 7336f01 commit 058fee3

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Control/DeepSeq.hs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
{-# OPTIONS_GHC -Wno-deprecations #-}
2222
#endif
2323

24+
#define BYTEARRAY_IN_BASE (__GLASGOW_HASKELL__ >= 903)
25+
-- At the moment of writing GHC source tree has not yet bumped `base` version,
26+
-- so using __GLASGOW_HASKELL__ as a proxy instead of MIN_VERSION_base(4,17,0).
27+
2428
-----------------------------------------------------------------------------
2529
-- |
2630
-- Module : Control.DeepSeq
@@ -161,6 +165,10 @@ import GHC.Tuple (Solo (..))
161165
#endif
162166
#endif
163167

168+
#if BYTEARRAY_IN_BASE
169+
import Data.Array.Byte (ByteArray(..))
170+
#endif
171+
164172
-- | Hidden internal type-class
165173
class GNFData arity f where
166174
grnf :: RnfArgs arity a -> f a -> ()
@@ -1046,3 +1054,12 @@ instance (NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6, NFDa
10461054
instance (NFData a1, NFData a2, NFData a3, NFData a4, NFData a5, NFData a6, NFData a7) =>
10471055
NFData2 ((,,,,,,,,) a1 a2 a3 a4 a5 a6 a7) where
10481056
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
1057+
1058+
----------------------------------------------------------------------------
1059+
-- ByteArray
1060+
1061+
#if BYTEARRAY_IN_BASE
1062+
-- |@since 1.4.6.0
1063+
instance NFData ByteArray where
1064+
rnf (ByteArray _) = ()
1065+
#endif

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
([#69](https://github.com/haskell/deepseq/pull/69))
77
* Add once again `infixr 0 deepseq`
88
([#56](https://github.com/haskell/deepseq/pull/56), [#74](https://github.com/haskell/deepseq/issues/74))
9+
* Add `NFData` instance for `ByteArray`
10+
([#65](https://github.com/haskell/deepseq/pull/65))
911

1012
## 1.4.6.1
1113

0 commit comments

Comments
 (0)