{-# LANGUAGE DeriveDataTypeable #-}
-{-# LANGUAGE StandaloneDeriving #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Hcompta.Lib.Strict where
-import Control.DeepSeq (NFData(..))
-import Data.Data
-import Data.Eq (Eq)
-import Data.Monoid (Monoid(..))
-import Text.Show (Show)
-import Prelude (seq)
+import Control.DeepSeq (NFData(..))
+import Data.Data
+import Data.Eq (Eq)
+import Data.Function ((.))
+import Data.Monoid (Monoid(..))
+import Data.NonNull (NonNull, toNullable)
+import Prelude (seq)
+import Text.Show (Show)
--- * Type 'Clusive'
+instance NFData s => NFData (NonNull s) where
+ rnf = rnf . toNullable
+-- * Type 'Clusive'
-- A data type to calculate an 'inclusive' value
-- (through some propagation mecanism,
-- eg. incorporating the values of the children of a tree node),
{ exclusive :: !a
, inclusive :: !a
} deriving (Data, Eq, Show, Typeable)
-instance -- Monoid
- Monoid a
- => Monoid (Clusive a) where
+instance Monoid a => Monoid (Clusive a) where
mempty = Clusive mempty mempty
mappend (Clusive e0 i0) (Clusive e1 i1) =
Clusive (e0`mappend`e1) (i0`mappend`i1)
-instance -- NFData
- NFData a =>
- NFData (Clusive a) where
+instance NFData a => NFData (Clusive a) where
rnf (Clusive e i) = rnf e `seq` rnf i