Skip to content

Commit bf68f14

Browse files
committed
Add GNFData instances for :*: and :+:
1 parent 0a098ab commit bf68f14

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Data/GADT/DeepSeq.hs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{-# LANGUAGE CPP #-}
22
{-# LANGUAGE GADTs #-}
3+
{-# LANGUAGE TypeOperators #-}
34
#if __GLASGOW_HASKELL__ >= 706
45
{-# LANGUAGE PolyKinds #-}
56
#endif
@@ -19,6 +20,10 @@ import Data.Functor.Product (Product (..))
1920
import Data.Functor.Sum (Sum (..))
2021
import Data.Type.Equality ((:~:) (..))
2122

23+
#if MIN_VERSION_base(4,6,0)
24+
import GHC.Generics ((:+:) (..), (:*:) (..))
25+
#endif
26+
2227
#if MIN_VERSION_base(4,9,0)
2328
#if MIN_VERSION_base(4,10,0)
2429
import Data.Type.Equality ((:~~:) (..))
@@ -49,6 +54,15 @@ instance (GNFData a, GNFData b) => GNFData (Sum a b) where
4954
grnf (InL x) = grnf x
5055
grnf (InR y) = grnf y
5156

57+
#if MIN_VERSION_base(4,6,0)
58+
instance (GNFData a, GNFData b) => GNFData (a :*: b) where
59+
grnf (a :*: b) = grnf a `seq` grnf b
60+
61+
instance (GNFData a, GNFData b) => GNFData (a :+: b) where
62+
grnf (L1 x) = grnf x
63+
grnf (R1 y) = grnf y
64+
#endif
65+
5266
-- | @since 1.0.3
5367
instance GNFData ((:~:) a) where
5468
grnf Refl = ()

0 commit comments

Comments
 (0)