{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module Hcompta.LCC.Account where import Control.DeepSeq (NFData(..)) import Data.Data (Data(..)) import Data.Eq (Eq(..)) import Data.List.NonEmpty (NonEmpty(..)) import Data.NonNull (NonNull) import qualified Data.MonoTraversable as MT import Data.Monoid (Monoid(..)) import qualified Data.NonNull as NonNull import Data.Ord (Ord(..)) import Data.Semigroup (Semigroup(..)) import qualified Data.Time.Clock as Time import qualified Data.TreeMap.Strict as TreeMap import Data.Typeable (Typeable) import Text.Show (Show) import Hcompta.LCC.Anchor import Hcompta.LCC.Tag import Hcompta.LCC.Name import qualified Hcompta as H -- * Type 'Account' newtype Account = Account (NonNull [Account_Section]) deriving (Data, Eq, MT.MonoFunctor, MT.MonoFoldable , NFData, Ord, Semigroup, Show, Typeable) type instance MT.Element Account = Account_Section instance H.Get (TreeMap.Path Account_Section) Account where get (Account n) = x :| xs where (x, xs) = NonNull.splitFirst n instance H.Get Account (TreeMap.Path Account_Section) where get (x :| xs) = Account (NonNull.ncons x xs) instance H.Account Account -- ** Type 'Account_Section' type Account_Section = Name -- * Type 'Account_Anchor' newtype Account_Anchor = Account_Anchor Anchor deriving (Data, Eq, Ord, NFData, Show, Typeable) -- * Type 'Account_Tag' newtype Account_Tag = Account_Tag Tag deriving (Data, Eq, NFData, Show, Typeable) instance MT.MonoFunctor Account_Tag where omap f (Account_Tag tag) = Account_Tag (f tag) type instance MT.Element Account_Tag = Tag type instance H.Tag_Path H.:@ Account_Tag = Tag_Path type instance H.Tag_Value H.:@ Account_Tag = Tag_Value -- ** Type 'Account_Tags' newtype Account_Tags = Account_Tags Tags deriving (Data, Eq, Monoid, NFData, Show, Typeable) type instance MT.Element Account_Tags = Account_Tag instance H.GetI H.Tag_Path Account_Tag where getI _ (Account_Tag tag) = tag_path tag instance H.SetI H.Tag_Path Account_Tag where setI _ tag_path = MT.omap (\tag -> tag{tag_path}) instance H.GetI H.Tag_Value Account_Tag where getI _ (Account_Tag tag) = tag_value tag instance H.SetI H.Tag_Value Account_Tag where setI _ tag_value = MT.omap (\tag -> tag{tag_value}) -- * Type 'Date' type Date = Time.UTCTime