{-# LANGUAGE CPP         #-}
#if __GLASGOW_HASKELL__ >= 704
{-# 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 (..))

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 (f :: * -> *) a. GNFData f => f a -> ()
grnf a a
a () -> () -> ()
`seq` b a -> ()
forall (f :: * -> *) a. 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 (f :: * -> *) a. GNFData f => f a -> ()
grnf a a
x
    grnf (InR b a
y) = b a -> ()
forall (f :: * -> *) a. GNFData f => f a -> ()
grnf b a
y