]> Git — Sourcephile - comptalang.git/blob - lib/Hcompta/Model/Journal.hs
Correction : LambdaCase n’est pas dans ghc-7.4 (Debian/wheezy) (bis)
[comptalang.git] / lib / Hcompta / Model / Journal.hs
1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# OPTIONS_GHC -fno-warn-orphans #-}
3 module Hcompta.Model.Journal where
4
5 import Data.Data
6 import qualified Data.Map.Strict as Data.Map
7 import Data.Typeable ()
8 import qualified Data.Foldable
9 import Data.Foldable (Foldable)
10
11 import qualified Hcompta.Model.Transaction as Transaction
12
13 data Journal
14 = Journal
15 { transactions :: Transaction.By_Date
16 } deriving (Data, Eq, Read, Show, Typeable)
17
18 nil :: Journal
19 nil =
20 Journal
21 { transactions = Data.Map.empty
22 }
23
24 union :: Journal -> Journal -> Journal
25 union
26 Journal
27 { transactions=t0
28 }
29 Journal
30 { transactions=t1
31 } =
32 Journal
33 { transactions = Data.Map.unionWith (++) t0 t1
34 }
35
36 unions :: Foldable t => t Journal -> Journal
37 unions =
38 Data.Foldable.foldl
39 Hcompta.Model.Journal.union
40 Hcompta.Model.Journal.nil