{-# LANGUAGE UndecidableInstances #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -- | Symantic for 'Journal'. module Hcompta.LCC.Sym.Journal where import Data.Eq (Eq) import Data.Function (($), (.)) import Data.Maybe (Maybe(..)) import Text.Show (Show(..)) import qualified Prelude () import Hcompta.LCC.Journal (Journal, PathFile(..)) import Hcompta.LCC.Posting (Date) import Hcompta.LCC.Sym.Date (tyDate) import Hcompta.LCC.Sym.FileSystem (tyPathFile) import qualified Hcompta.LCC.Journal as LCC import Language.Symantic import Language.Symantic.Lib (a0) -- * Class 'Sym_Journal' type instance Sym (Proxy Journal) = Sym_Journal class Sym_Journal term where journal :: Journal j -> term (Journal j) journal_file :: term (Journal j) -> term PathFile journal_last_read_time :: term (Journal j) -> term Date journal_content :: term (Journal j) -> term j default journal :: Sym_Journal (UnT term) => Trans term => Journal j -> term (Journal j) default journal_file :: Sym_Journal (UnT term) => Trans term => term (Journal j) -> term PathFile default journal_last_read_time :: Sym_Journal (UnT term) => Trans term => term (Journal j) -> term Date default journal_content :: Sym_Journal (UnT term) => Trans term => term (Journal j) -> term j journal = trans . journal journal_file = trans1 journal_file journal_last_read_time = trans1 journal_last_read_time journal_content = trans1 journal_content instance Sym_Journal Eval where journal = Eval journal_file = eval1 LCC.journal_file journal_last_read_time = eval1 LCC.journal_last_read_time journal_content = eval1 LCC.journal_content instance Sym_Journal View where journal _ = View $ \_v _p -> "Journal.journal" journal_file = view1 "Journal.file" journal_last_read_time = view1 "Journal.last_read_time" journal_content = view1 "Journal.content" instance (Sym_Journal r1, Sym_Journal r2) => Sym_Journal (Dup r1 r2) where journal j = journal j `Dup` journal j journal_file = dup1 @Sym_Journal journal_file journal_last_read_time = dup1 @Sym_Journal journal_last_read_time journal_content = dup1 @Sym_Journal journal_content instance (Sym_Journal term, Sym_Lambda term) => Sym_Journal (BetaT term) instance FixityOf Journal instance ClassInstancesFor Journal where proveConstraintFor _ (TyApp _ tq@(TyConst _ _ q) (TyApp _ c j)) | Just HRefl <- proj_ConstKiTy @(K Journal) @Journal c = case () of _ | Just Refl <- proj_Const @Eq q , Just Dict <- proveConstraint (tq `tyApp` j) -> Just Dict | Just Refl <- proj_Const @Show q , Just Dict <- proveConstraint (tq `tyApp` j) -> Just Dict _ -> Nothing proveConstraintFor _c _q = Nothing instance TypeInstancesFor Journal instance Gram_Term_AtomsFor src ss g Journal instance (Source src, Inj_Sym ss Journal) => ModuleFor src ss Journal where moduleFor _s = ["Journal"] `moduleWhere` [ "file" := teJournal_file , "last_read_time" := teJournal_last_read_time , "content" := teJournal_content ] tyJournal :: Source src => Inj_Len vs => Type src vs a -> Type src vs (Journal a) tyJournal a = tyConstLen @(K Journal) @Journal (lenVars a) `tyApp` a teJournal :: Source src => Inj_Sym ss Journal => Journal a -> Term src ss ts '[Proxy a] (Journal a) teJournal j = Term noConstraint (tyJournal a0) $ teSym @Journal $ journal j teJournal_file :: Source src => Inj_Sym ss Journal => Term src ss ts '[Proxy a] (Journal a -> PathFile) teJournal_file = Term noConstraint (tyJournal a0 ~> tyPathFile) $ teSym @Journal $ lam1 journal_file teJournal_last_read_time :: Source src => Inj_Sym ss Journal => Term src ss ts '[Proxy a] (Journal a -> Date) teJournal_last_read_time = Term noConstraint (tyJournal a0 ~> tyDate) $ teSym @Journal $ lam1 journal_last_read_time teJournal_content :: Source src => Inj_Sym ss Journal => Term src ss ts '[Proxy a] (Journal a -> a) teJournal_content = Term noConstraint (tyJournal a0 ~> a0) $ teSym @Journal $ lam1 journal_content