1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# LANGUAGE FlexibleInstances #-}
3 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
4 {-# LANGUAGE MultiParamTypeClasses #-}
5 {-# LANGUAGE NamedFieldPuns #-}
6 {-# LANGUAGE TypeFamilies #-}
7 {-# OPTIONS_GHC -fno-warn-orphans #-}
8 module Hcompta.LCC.Tag where
10 import Control.DeepSeq (NFData(..))
11 import Data.Data (Data(..))
12 import Data.Eq (Eq(..))
13 import Data.Function (($), flip)
14 import Data.Monoid (Monoid(..))
15 import Data.NonNull (NonNull)
16 import Data.Ord (Ord(..))
17 import Data.Semigroup (Semigroup(..))
18 import Data.Text (Text)
19 import Data.TreeMap.Strict (TreeMap)
20 import Data.Typeable (Typeable)
22 import Text.Show (Show)
23 import qualified Data.MonoTraversable as MT
24 import qualified Data.TreeMap.Strict as TreeMap
26 import qualified Hcompta as H ()
27 import Hcompta.LCC.Name
32 { tag_path :: Tag_Path
33 , tag_data :: Tag_Data
34 } deriving (Data, Eq, Ord, Show, Typeable)
36 instance NFData Tag where
37 rnf (Tag p d) = rnf p `seq` rnf d
40 newtype Tag_Path = Tag_Path (NonNull [Tag_Path_Section])
41 deriving (Data, Eq, NFData, Ord, Semigroup, Show, Typeable)
43 -- instance H.Tag_Path Tag_Path
44 type Tag_Path_Section = Name
47 newtype Tag_Data = Tag_Data Text
48 deriving (Data, Eq, NFData, Ord, Show, Typeable)
50 -- instance H.Tag_Data Tag_Data
54 = Tags (TreeMap Tag_Path_Section [Tag_Data])
55 deriving (Data, Eq, NFData, Ord, Show, Typeable)
57 type instance MT.Element Tags = Tag
59 instance Semigroup Tags where
61 Tags $ TreeMap.union (flip (<>)) x y
62 instance Monoid Tags where