1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# OPTIONS_GHC -fno-warn-orphans #-}
3 module Hcompta.Lib.Strict where
5 import Control.DeepSeq (NFData(..))
8 import Data.Function ((.))
9 import Data.Monoid (Monoid(..))
10 import Data.NonNull (NonNull, toNullable)
12 import Text.Show (Show)
14 instance NFData s => NFData (NonNull s) where
15 rnf = rnf . toNullable
18 -- A data type to calculate an 'inclusive' value
19 -- (through some propagation mecanism,
20 -- eg. incorporating the values of the children of a tree node),
21 -- while keeping the original 'exclusive' value
22 -- (eg. the original value of a tree node).
27 } deriving (Data, Eq, Show, Typeable)
28 instance Monoid a => Monoid (Clusive a) where
29 mempty = Clusive mempty mempty
30 mappend (Clusive e0 i0) (Clusive e1 i1) =
31 Clusive (e0`mappend`e1) (i0`mappend`i1)
32 instance NFData a => NFData (Clusive a) where
33 rnf (Clusive e i) = rnf e `seq` rnf i