1 {-# LANGUAGE DeriveDataTypeable #-}
2 module Hcompta.Model.Account where
4 import Data.Data (Data)
5 import qualified Data.List
6 import Data.Typeable (Typeable)
7 -- import qualified Text.Parsec as P
8 -- import Text.Parsec (Stream, ParsecT, (<|>), (<?>))
10 -- import qualified Hcompta.Model.Account.Path as Path
11 import Hcompta.Lib.Regex (Regex)
13 -- * The 'Account' type
21 -- | Return the given 'Account' without its last 'Name' is any.
22 ascending :: Account -> Account
25 ascending (n:a) = n:ascending a
27 -- | Apply the given function to all the prefixes of the given 'Account'.
28 fold :: Account -> (Account -> a -> a) -> a -> a
31 loop :: Account -> Account -> (Account -> a -> a) -> a -> a
32 loop _path [] _f acc = acc
33 loop path (name:account) f acc =
34 let next = (Hcompta.Model.Account.++) path [name] in
35 loop next account f (f next acc)
38 -- | Return the concatenation of the given 'Account'.
39 (++) :: Account -> Account -> Account
49 deriving (Data, Eq, Read, Show, Typeable)
51 -- * The 'Filter' type
54 = Pattern_Exact Account
57 deriving (Read, Show, Typeable)