1 {-# LANGUAGE DeriveDataTypeable #-}
2 module Hcompta.Model.Account where
5 import Data.Function (on)
6 import qualified Data.List
7 import qualified Data.Map
9 import Data.Maybe (fromMaybe)
10 import Data.Typeable ()
12 -- import qualified Hcompta.Model.Account.Path as Path
13 import qualified Hcompta.Model.Amount as Amount
14 import Hcompta.Model.Amount (Amount)
15 import qualified Hcompta.Model.Transaction.Tag as Tag
16 import Hcompta.Model.Transaction.Tag (Tag)
18 -- * The 'Account' type
26 -- | Apply the given function to all the prefixes of the given 'Account'.
27 fold :: Account -> (Account -> a -> a) -> a -> a
30 loop :: Account -> Account -> (Account -> a -> a) -> a -> a
31 loop _path [] _f acc = acc
32 loop path (name:account) f acc =
33 let next = path++[name] in
34 loop next account f (f next acc)
37 -- | Return the given 'Account' without its last 'Name'.
38 chomp :: Account -> Account
41 chomp (n:a) = n:chomp a