1 {-# LANGUAGE NoMonomorphismRestriction #-}
4 ( module Hcompta.LCC.Sym
5 , module Hcompta.LCC.Sym.Account
6 , module Hcompta.LCC.Sym.Addable
7 , module Hcompta.LCC.Sym.Amount
8 , module Hcompta.LCC.Sym.Date
9 , module Hcompta.LCC.Sym.FileSystem
10 , module Hcompta.LCC.Sym.Journal
11 , module Hcompta.LCC.Sym.Negable
12 , module Hcompta.LCC.Sym.Posting
13 , module Hcompta.LCC.Sym.Quantity
14 , module Hcompta.LCC.Sym.Subable
15 , module Hcompta.LCC.Sym.Transaction
16 , module Hcompta.LCC.Sym.Unit
17 , module Hcompta.LCC.Sym.Zipper
20 import Hcompta.LCC.Sym.Account
21 import Hcompta.LCC.Sym.Addable
22 import Hcompta.LCC.Sym.Amount
23 import Hcompta.LCC.Sym.Date
24 import Hcompta.LCC.Sym.FileSystem
25 import Hcompta.LCC.Sym.Journal
26 import Hcompta.LCC.Sym.Negable
27 import Hcompta.LCC.Sym.Posting
28 import Hcompta.LCC.Sym.Quantity
29 import Hcompta.LCC.Sym.Subable
30 import Hcompta.LCC.Sym.Transaction
31 import Hcompta.LCC.Sym.Unit
32 import Hcompta.LCC.Sym.Zipper
34 import Hcompta.LCC.Account (Account)
35 import Hcompta.LCC.Amount (Amounts, Quantity, Unit)
36 import Hcompta.LCC.Journal (Journal, PathFile)
37 import Hcompta.LCC.Posting (Posting, Date)
38 import Hcompta.LCC.Transaction (Transaction)
39 import Hcompta.Quantity (Addable, Negable, Subable)
41 import Control.Applicative (Alternative)
42 import Data.Bool (Bool)
43 import Data.Either (Either(..))
45 import Data.Foldable (Foldable)
46 import Data.Map.Strict (Map)
47 import Data.Maybe (Maybe)
48 import Data.NonNull (NonNull)
51 import Data.Traversable (Traversable)
52 import Data.TreeMap.Strict.Zipper (Zipper)
53 import Text.Show (Show)
56 import Hcompta.LCC.Grammar
57 import Hcompta.LCC.Journal
58 import Hcompta.LCC.Read
59 import Language.Symantic.Grammar
60 import qualified Text.Megaparsec as P
61 import qualified Data.Strict as S
63 import Prelude hiding (read, readFile)
97 = Error_App_not_applicable
98 | Error_App_type_mismatch (Sym.EType cs) (Sym.EType cs)
102 :: Sym.Inj_TyConst cs (->)
103 => Sym.ETermClosed cs is
104 -> Sym.ETermClosed cs is
105 -> Either (Error_App cs) (Sym.ETermClosed cs is)
106 app (Sym.ETermClosed ty_f (Sym.TermClosed te_f))
107 (Sym.ETermClosed ty_a (Sym.TermClosed te_a)) =
109 ty_fun Sym.:$ ty_arg Sym.:$ ty_res
110 | Just Refl <- Sym.kind_of ty_fun `Sym.eq_skind` (Sym.kind::Sym.SKind (Kind.Type -> Kind.Type -> Kind.Type))
111 , Just Refl <- ty_fun `Sym.eq_Type` Sym.ty @(->) ->
112 case ty_arg `Sym.eq_Type` ty_a of
113 Just Refl -> Right $ Sym.ETermClosed ty_res $ Sym.TermClosed $ te_f Sym..$ te_a
114 Nothing -> Left $ Error_App_type_mismatch (Sym.EType ty_arg) (Sym.EType ty_a)
115 _ -> Left $ Error_App_not_applicable
116 feed_args :: Sym.TermAVT src -> [Sym.TermAVT src] -> Sym.TermAVT src
117 feed_args te as = go te as
122 Right f' -> f' `go` as
123 Left _err -> f `go` xs
128 IO ( ( Either (P.ParseError Char P.Dec)
129 (S.Either [At SRC (Error_Journal SRC)] (CanonFile, Journal [Transaction]))
130 , Context_Read SRC [Transaction] )
131 , Context_Sym SRC SS )
132 x0 = readJournal @SS "./Hcompta/LCC/Journal/02.jnl" (:)
135 -- :: CF (P.ParsecT P.Dec Text m) a
136 :: ( m ~ S.StateT (Context_Read j) (S.StateT (Context_Sym cs is) IO)
138 , cs ~ Sym.TyConsts_of_Ifaces is
139 -- , e ~ P.ParseError Char P.Dec
141 => CF (P.ParsecT P.Dec Text m)
143 , Either (At (Sym.Error_Term Meta cs is))