1 {-# LANGUAGE NoMonomorphismRestriction #-}
2 {-# LANGUAGE UndecidableInstances #-}
5 ( module Hcompta.LCC.Sym
6 , module Hcompta.LCC.Sym.Account
7 , module Hcompta.LCC.Sym.Addable
8 , module Hcompta.LCC.Sym.Amount
9 , module Hcompta.LCC.Sym.Balance
10 , module Hcompta.LCC.Sym.Chart
11 , module Hcompta.LCC.Sym.Compta
12 , module Hcompta.LCC.Sym.Date
13 , module Hcompta.LCC.Sym.FileSystem
14 , module Hcompta.LCC.Sym.Journal
15 , module Hcompta.LCC.Sym.Negable
16 , module Hcompta.LCC.Sym.Posting
17 , module Hcompta.LCC.Sym.Quantity
18 , module Hcompta.LCC.Sym.Subable
19 , module Hcompta.LCC.Sym.Sumable
20 , module Hcompta.LCC.Sym.Transaction
21 , module Hcompta.LCC.Sym.Unit
22 , module Hcompta.LCC.Sym.Zeroable
23 , module Hcompta.LCC.Sym.Zipper
26 import Language.Symantic (type (++))
27 import qualified Language.Symantic.Lib as Sym
29 import Hcompta.LCC.Sym.Account
30 import Hcompta.LCC.Sym.Addable
31 import Hcompta.LCC.Sym.Amount
32 import Hcompta.LCC.Sym.Balance
33 import Hcompta.LCC.Sym.Chart
34 import Hcompta.LCC.Sym.Compta
35 import Hcompta.LCC.Sym.Date
36 import Hcompta.LCC.Sym.FileSystem
37 import Hcompta.LCC.Sym.Journal
38 import Hcompta.LCC.Sym.Negable
39 import Hcompta.LCC.Sym.Posting
40 import Hcompta.LCC.Sym.Quantity
41 import Hcompta.LCC.Sym.Subable
42 import Hcompta.LCC.Sym.Sumable
43 import Hcompta.LCC.Sym.Transaction
44 import Hcompta.LCC.Sym.Unit
45 import Hcompta.LCC.Sym.Zeroable
46 import Hcompta.LCC.Sym.Zipper
48 import qualified Hcompta.LCC.Account as LCC
49 import qualified Hcompta.LCC.Amount as LCC
50 import qualified Hcompta.LCC.Balance as LCC
51 import qualified Hcompta.LCC.Chart as LCC
52 import qualified Hcompta.LCC.Compta as LCC
53 import qualified Hcompta.LCC.IO as LCC
54 import qualified Hcompta.LCC.Journal as LCC
55 import qualified Hcompta.LCC.Posting as LCC
56 import qualified Hcompta.LCC.Source as LCC
57 import qualified Hcompta.LCC.Transaction as LCC
58 import qualified Hcompta as H
60 import Control.Applicative (Applicative, Alternative)
61 import Control.Monad (Monad)
62 import Data.Bool (Bool)
63 import Data.Either (Either(..))
65 import Data.Foldable (Foldable)
66 import Data.Functor (Functor)
67 import Data.List.NonEmpty (NonEmpty(..))
68 import Data.Map.Strict (Map)
69 import Data.Maybe (Maybe)
70 import Data.MonoTraversable (MonoFunctor, MonoFoldable)
71 import Data.Monoid (Monoid)
72 import Data.NonNull (NonNull)
75 import Data.Semigroup (Semigroup)
76 import Data.Sequences (SemiSequence, IsSequence)
77 import Data.Text (Text)
78 import Data.Traversable (Traversable)
79 import Data.TreeMap.Strict.Zipper (Zipper)
80 import Prelude (Integer)
82 import Text.Show (Show)
84 type SS = Proxy (LCC.Compta SRC SS') ': SS'
85 type SRC = LCC.Source (NonEmpty LCC.SourcePos) SS'
112 , Proxy LCC.Transaction
138 = Error_App_not_applicable
139 | Error_App_type_mismatch (Sym.EType cs) (Sym.EType cs)
143 :: Sym.Inj_TyConst cs (->)
144 => Sym.ETermClosed cs is
145 -> Sym.ETermClosed cs is
146 -> Either (Error_App cs) (Sym.ETermClosed cs is)
147 app (Sym.ETermClosed ty_f (Sym.TermClosed te_f))
148 (Sym.ETermClosed ty_a (Sym.TermClosed te_a)) =
150 ty_fun Sym.:$ ty_arg Sym.:$ ty_res
151 | Just Refl <- Sym.kind_of ty_fun `Sym.eq_skind` (Sym.kind::Sym.SKind (Kind.Type -> Kind.Type -> Kind.Type))
152 , Just Refl <- ty_fun `Sym.eq_Type` Sym.ty @(->) ->
153 case ty_arg `Sym.eq_Type` ty_a of
154 Just Refl -> Right $ Sym.ETermClosed ty_res $ Sym.TermClosed $ te_f Sym..$ te_a
155 Nothing -> Left $ Error_App_type_mismatch (Sym.EType ty_arg) (Sym.EType ty_a)
156 _ -> Left $ Error_App_not_applicable
157 feed_args :: Sym.TermAVT src -> [Sym.TermAVT src] -> Sym.TermAVT src
158 feed_args te as = go te as
163 Right f' -> f' `go` as
164 Left _err -> f `go` xs
169 IO ( ( Either (P.ParseError Char P.Dec)
170 (S.Either [At SRC (Error_Compta SRC)] (CanonFile, Journal [Transaction]))
171 , Context_Read SRC [Transaction] )
172 , Context_Sym SRC SS )
173 x0 = readJournal @SS "./Hcompta/LCC/Journal/02.jnl" (:)
176 -- :: CF (P.ParsecT P.Dec Text m) a
177 :: ( m ~ S.StateT (Context_Read j) (S.StateT (Context_Sym cs is) IO)
179 , cs ~ Sym.TyConsts_of_Ifaces is
180 -- , e ~ P.ParseError Char P.Dec
182 => CF (P.ParsecT P.Dec Text m)
184 , Either (At (Sym.Error_Term Meta cs is))