]> Git — Sourcephile - comptalang.git/blob - lib/Hcompta/Lib/Strict.hs
Add make target tar.
[comptalang.git] / lib / Hcompta / Lib / Strict.hs
1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# OPTIONS_GHC -fno-warn-orphans #-}
3 module Hcompta.Lib.Strict where
4
5 import Control.DeepSeq (NFData(..))
6 import Data.Data
7 import Data.Eq (Eq)
8 import Data.Function ((.))
9 import Data.Monoid (Monoid(..))
10 import Data.NonNull (NonNull, toNullable)
11 import Prelude (seq)
12 import Text.Show (Show)
13
14 instance NFData s => NFData (NonNull s) where
15 rnf = rnf . toNullable
16
17 -- * Type 'Clusive'
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).
23 data Clusive a
24 = Clusive
25 { exclusive :: !a
26 , inclusive :: !a
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