]> Git — Sourcephile - comptalang.git/blob - lcc/Hcompta/LCC/Sym/Journal.hs
Commit old WIP.
[comptalang.git] / lcc / Hcompta / LCC / Sym / Journal.hs
1 {-# LANGUAGE UndecidableInstances #-}
2 {-# OPTIONS_GHC -fno-warn-orphans #-}
3 -- | Symantic for 'Journal'.
4 module Hcompta.LCC.Sym.Journal where
5
6 import Data.Function (($), (.))
7 import qualified Prelude ()
8 import Data.Typeable (Typeable)
9
10 import Hcompta.LCC.IO (PathFile(..))
11 import Hcompta.LCC.Chart (Chart)
12 import Hcompta.LCC.Journal (Journal)
13 import Hcompta.LCC.Posting (Date)
14 import Hcompta.LCC.Sym.Chart (tyChart)
15 import Hcompta.LCC.Sym.Date (tyDate)
16 import Hcompta.LCC.Sym.FileSystem (tyPathFile)
17 import qualified Hcompta.LCC.Journal as LCC
18
19 import Language.Symantic
20 import Language.Symantic.Lib (a0)
21
22 -- * Class 'Sym_Journal'
23 type instance Sym (Journal sou) = Sym_Journal
24 class Sym_Journal term where
25 journal :: Journal sou j -> term (Journal sou j)
26 journal_file :: term (Journal sou j) -> term PathFile
27 journal_last_read_time :: term (Journal sou j) -> term Date
28 journal_chart :: term (Journal sou j) -> term Chart
29 journal_content :: term (Journal sou j) -> term j
30 default journal :: Sym_Journal (UnT term) => Trans term => Journal sou j -> term (Journal sou j)
31 default journal_file :: Sym_Journal (UnT term) => Trans term => term (Journal sou j) -> term PathFile
32 default journal_last_read_time :: Sym_Journal (UnT term) => Trans term => term (Journal sou j) -> term Date
33 default journal_chart :: Sym_Journal (UnT term) => Trans term => term (Journal sou j) -> term Chart
34 default journal_content :: Sym_Journal (UnT term) => Trans term => term (Journal sou j) -> term j
35 journal = trans . journal
36 journal_file = trans1 journal_file
37 journal_last_read_time = trans1 journal_last_read_time
38 journal_chart = trans1 journal_chart
39 journal_content = trans1 journal_content
40
41 instance Sym_Journal Eval where
42 journal = Eval
43 journal_file = eval1 LCC.journal_file
44 journal_last_read_time = eval1 LCC.journal_last_read_time
45 journal_chart = eval1 LCC.journal_chart
46 journal_content = eval1 LCC.journal_content
47 instance Sym_Journal View where
48 journal _ = View $ \_v _p -> "Journal.journal"
49 journal_file = view1 "Journal.file"
50 journal_last_read_time = view1 "Journal.last_read_time"
51 journal_chart = view1 "Journal.chart"
52 journal_content = view1 "Journal.content"
53 instance (Sym_Journal r1, Sym_Journal r2) => Sym_Journal (Dup r1 r2) where
54 journal j = journal j `Dup` journal j
55 journal_file = dup1 @Sym_Journal journal_file
56 journal_last_read_time = dup1 @Sym_Journal journal_last_read_time
57 journal_chart = dup1 @Sym_Journal journal_chart
58 journal_content = dup1 @Sym_Journal journal_content
59 instance (Sym_Journal term, Sym_Lambda term) => Sym_Journal (BetaT term)
60
61 instance Typeable sou => NameTyOf (Journal sou) where
62 nameTyOf _c = ["Journal"] `Mod` "Journal"
63 instance FixityOf (Journal sou)
64 instance Typeable sou => ClassInstancesFor (Journal sou) where
65 instance TypeInstancesFor (Journal src)
66
67 instance Gram_Term_AtomsFor src ss g (Journal sou)
68 instance (Typeable sou, Source src, SymInj ss (Journal sou)) => ModuleFor src ss (Journal sou) where
69 moduleFor = ["Journal"] `moduleWhere`
70 [ "file" := teJournal_file @sou
71 , "last_read_time" := teJournal_last_read_time @sou
72 , "chart" := teJournal_chart @sou
73 , "content" := teJournal_content @sou
74 ]
75
76 tyJournal :: forall sou src vs a. Typeable sou => Source src => LenInj vs => Type src vs a -> Type src vs (Journal sou a)
77 tyJournal a = tyConstLen @(K (Journal sou)) @(Journal sou) (lenVars a) `tyApp` a
78
79 teJournal :: forall sou src ss ts a. Typeable sou => Source src => SymInj ss (Journal sou) => Journal sou a -> Term src ss ts '[Proxy a] (() #> Journal sou a)
80 teJournal j = Term noConstraint (tyJournal a0) $ teSym @(Journal sou) $ journal j
81
82 teJournal_file :: forall sou src ss ts a. Typeable sou => Source src => SymInj ss (Journal sou) => Term src ss ts '[Proxy a] (() #> (Journal sou a -> PathFile))
83 teJournal_file = Term noConstraint (tyJournal a0 ~> tyPathFile) $ teSym @(Journal sou) $ lam1 journal_file
84
85 teJournal_last_read_time :: forall sou src ss ts a. Typeable sou => Source src => SymInj ss (Journal sou) => Term src ss ts '[Proxy a] (() #> (Journal sou a -> Date))
86 teJournal_last_read_time = Term noConstraint (tyJournal a0 ~> tyDate) $ teSym @(Journal sou) $ lam1 journal_last_read_time
87
88 teJournal_chart :: forall sou src ss ts a. Typeable sou => Source src => SymInj ss (Journal sou) => Term src ss ts '[Proxy a] (() #> (Journal sou a -> Chart))
89 teJournal_chart = Term noConstraint (tyJournal a0 ~> tyChart) $ teSym @(Journal sou) $ lam1 journal_chart
90
91 teJournal_content :: forall sou src ss ts a. Typeable sou => Source src => SymInj ss (Journal sou) => Term src ss ts '[Proxy a] (() #> (Journal sou a -> a))
92 teJournal_content = Term noConstraint (tyJournal a0 ~> a0) $ teSym @(Journal sou) $ lam1 journal_content