]> Git — Sourcephile - comptalang.git/blob - lib/Hcompta/Lib/Strict.hs
Cleanup hcompta-lib.
[comptalang.git] / lib / Hcompta / Lib / Strict.hs
1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# LANGUAGE StandaloneDeriving #-}
3 {-# OPTIONS_GHC -fno-warn-orphans #-}
4 module Hcompta.Lib.Strict where
5
6 import Control.DeepSeq (NFData(..))
7 import Data.Data
8 import Data.Eq (Eq)
9 import Data.Monoid (Monoid(..))
10 import Text.Show (Show)
11 import Prelude (seq)
12
13 -- * Type 'Clusive'
14
15 -- A data type to calculate an 'inclusive' value
16 -- (through some propagation mecanism,
17 -- eg. incorporating the values of the children of a tree node),
18 -- while keeping the original 'exclusive' value
19 -- (eg. the original value of a tree node).
20 data Clusive a
21 = Clusive
22 { exclusive :: !a
23 , inclusive :: !a
24 } deriving (Data, Eq, Show, Typeable)
25 instance -- Monoid
26 Monoid a
27 => Monoid (Clusive a) where
28 mempty = Clusive mempty mempty
29 mappend (Clusive e0 i0) (Clusive e1 i1) =
30 Clusive (e0`mappend`e1) (i0`mappend`i1)
31 instance -- NFData
32 NFData a =>
33 NFData (Clusive a) where
34 rnf (Clusive e i) = rnf e `seq` rnf i