1 {-# LANGUAGE DeriveDataTypeable #-}
 
   2 {-# LANGUAGE StandaloneDeriving #-}
 
   3 {-# OPTIONS_GHC -fno-warn-orphans #-}
 
   4 module Hcompta.Lib.Strict where
 
   6 import Control.DeepSeq (NFData(..))
 
   9 import Data.Function ((.))
 
  10 import Data.Monoid (Monoid(..))
 
  11 import Data.NonNull (NonNull, toNullable)
 
  13 import Text.Show (Show)
 
  15 instance NFData s => NFData (NonNull s) where
 
  16         rnf = rnf . toNullable
 
  20 -- A data type to calculate an 'inclusive' value
 
  21 -- (through some propagation mecanism,
 
  22 -- eg. incorporating the values of the children of a tree node),
 
  23 -- while keeping the original 'exclusive' value
 
  24 -- (eg. the original value of a tree node).
 
  29  } deriving (Data, Eq, Show, Typeable)
 
  32  => Monoid (Clusive a) where
 
  33         mempty = Clusive mempty mempty
 
  34         mappend (Clusive e0 i0) (Clusive e1 i1) =
 
  35                 Clusive (e0`mappend`e1) (i0`mappend`i1)
 
  38  NFData (Clusive a) where
 
  39         rnf (Clusive e i)  = rnf e `seq` rnf i