]> Git — Sourcephile - comptalang.git/blob - lcc/Hcompta/LCC/Compta.hs
Remove cli/
[comptalang.git] / lcc / Hcompta / LCC / Compta.hs
1 module Hcompta.LCC.Compta where
2
3 import Data.Eq (Eq)
4 import Data.Map.Strict (Map)
5 import Data.Text (Text)
6 import Text.Show (Show)
7 import qualified Data.MonoTraversable as MT
8
9 import Language.Symantic as Sym
10 import Hcompta.LCC.Amount
11 import Hcompta.LCC.Chart
12 import Hcompta.LCC.Journal
13
14 -- * Type 'Compta'
15 --
16 -- NOTE: 'Compta' is recursively prepended to @ss@ in 'compta_modules' here,
17 -- where it is possible. It is more simple than introducing some fix-point wrapping @ss@
18 -- to include 'Compta' later, especially because this fix-point
19 -- would not be a type-level list like @ss@, hence not matching Symantic's API.
20 data Compta src ss j
21 = Compta
22 { compta_chart :: Chart
23 , compta_journals :: Journals j
24 , compta_modules :: Sym.Modules src (Sym.Proxy (Compta src ss) ': ss)
25 , compta_style_amounts :: Style_Amounts
26 , compta_terms :: Terms
27 -- , compta_code :: Map Name Text
28 } deriving (Eq, Show)
29
30 -- * Type 'Terms'
31 type Terms = Map (Sym.Mod Sym.NameTe) Text
32
33 type instance MT.Element (Compta src ss a) = Journal a
34 instance MT.MonoFunctor (Compta src ss a) where
35 omap f c@Compta{compta_journals=js} = c{compta_journals = MT.omap f js}
36 instance MT.MonoFoldable (Compta src ss a) where
37 ofoldMap f Compta{compta_journals=m} = MT.ofoldMap f m
38 ofoldr f a Compta{compta_journals=m} = MT.ofoldr f a m
39 ofoldl' f a Compta{compta_journals=m} = MT.ofoldl' f a m
40 ofoldr1Ex f Compta{compta_journals=m} = MT.ofoldr1Ex f m
41 ofoldl1Ex' f Compta{compta_journals=m} = MT.ofoldl1Ex' f m