{-# LANGUAGE CPP #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeOperators #-}
#if __GLASGOW_HASKELL__ >= 706
{-# LANGUAGE PolyKinds #-}
#endif
#if __GLASGOW_HASKELL__ >= 810
{-# LANGUAGE StandaloneKindSignatures #-}
#endif
#if (__GLASGOW_HASKELL__ >= 704 && __GLASGOW_HASKELL__ < 707) || __GLASGOW_HASKELL__ >= 801
{-# LANGUAGE Safe #-}
#elif __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE Trustworthy #-}
#endif
module Data.GADT.DeepSeq (
GNFData (..),
) where
import Data.Functor.Product (Product (..))
import Data.Functor.Sum (Sum (..))
import Data.Type.Equality ((:~:) (..))
#if MIN_VERSION_base(4,6,0)
import GHC.Generics ((:+:) (..), (:*:) (..))
#endif
#if MIN_VERSION_base(4,9,0)
#if MIN_VERSION_base(4,10,0)
import Data.Type.Equality ((:~~:) (..))
#else
import Data.Type.Equality.Hetero ((:~~:) (..))
#endif
#endif
#if MIN_VERSION_base(4,10,0)
import qualified Type.Reflection as TR
#endif
#if __GLASGOW_HASKELL__ >= 810
import Data.Kind (Type, Constraint)
#endif
#if __GLASGOW_HASKELL__ >= 810
type GNFData :: (k -> Type) -> Constraint
#endif
class GNFData f where
grnf :: f a -> ()
instance (GNFData a, GNFData b) => GNFData (Product a b) where
grnf :: Product a b a -> ()
grnf (Pair a a
a b a
b) = a a -> ()
forall k (f :: k -> *) (a :: k). GNFData f => f a -> ()
grnf a a
a () -> () -> ()
`seq` b a -> ()
forall k (f :: k -> *) (a :: k). GNFData f => f a -> ()
grnf b a
b
instance (GNFData a, GNFData b) => GNFData (Sum a b) where
grnf :: Sum a b a -> ()
grnf (InL a a
x) = a a -> ()
forall k (f :: k -> *) (a :: k). GNFData f => f a -> ()
grnf a a
x
grnf (InR b a
y) = b a -> ()
forall k (f :: k -> *) (a :: k). GNFData f => f a -> ()
grnf b a
y
#if MIN_VERSION_base(4,6,0)
instance (GNFData a, GNFData b) => GNFData (a :*: b) where
grnf :: (:*:) a b a -> ()
grnf (a a
a :*: b a
b) = a a -> ()
forall k (f :: k -> *) (a :: k). GNFData f => f a -> ()
grnf a a
a () -> () -> ()
`seq` b a -> ()
forall k (f :: k -> *) (a :: k). GNFData f => f a -> ()
grnf b a
b
instance (GNFData a, GNFData b) => GNFData (a :+: b) where
grnf :: (:+:) a b a -> ()
grnf (L1 a a
x) = a a -> ()
forall k (f :: k -> *) (a :: k). GNFData f => f a -> ()
grnf a a
x
grnf (R1 b a
y) = b a -> ()
forall k (f :: k -> *) (a :: k). GNFData f => f a -> ()
grnf b a
y
#endif
instance GNFData ((:~:) a) where
grnf :: (a :~: a) -> ()
grnf a :~: a
Refl = ()
#if MIN_VERSION_base(4,9,0)
instance GNFData ((:~~:) a) where
grnf :: (a :~~: a) -> ()
grnf a :~~: a
HRefl = ()
#endif
#if MIN_VERSION_base(4,10,0)
instance GNFData TR.TypeRep where
grnf :: TypeRep a -> ()
grnf = TypeRep a -> ()
forall k (a :: k). TypeRep a -> ()
TR.rnfTypeRep
#endif