1 {-# LANGUAGE DisambiguateRecordFields #-}
2 {-# LANGUAGE DuplicateRecordFields #-}
3 {-# LANGUAGE FlexibleInstances #-}
4 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
5 module Language.DTC.Document
6 ( module Language.DTC.Document
10 import Data.Default.Class (Default(..))
11 import Data.Default.Instances.Containers ()
13 import Data.Function (on)
15 import Data.Map.Strict (Map)
16 import Data.Maybe (Maybe(..))
17 import Data.Monoid (Monoid(..))
18 import Data.Ord (Ord(..))
19 import Data.Semigroup (Semigroup(..))
20 import Data.Sequence (Seq)
21 import Data.Text (Text)
22 import Data.TreeSeq.Strict (Tree, Trees)
23 import Text.Show (Show)
33 instance Default Document where
44 instance Default Head where
55 , editor :: Maybe Entity
61 , includes :: [Include]
63 instance Default About where
76 instance Semigroup About where
78 { titles = titles x <> titles y
79 , url = url x <> url y
80 , authors = authors x <> authors y
81 , editor = editor x <> editor y
82 , date = date x <> date y
83 , version = version x <> version y
84 , keywords = keywords x <> keywords y
85 , links = links x <> links y
86 , series = series x <> series y
87 , includes = includes x <> includes y
91 type Body = Trees BodyKey BodyValue
95 = Section { pos :: Pos
96 , attrs :: CommonAttrs
102 -- ** Type 'BodyValue'
105 , attrs :: CommonAttrs
109 , attrs :: CommonAttrs
112 | Figure { pos :: Pos
113 , attrs :: CommonAttrs
119 , attrs :: CommonAttrs
128 { posAncestors :: PosPath
129 , posAncestorsWithFigureNames :: PosPath
130 , posPrecedingsSiblings :: Map XmlName Rank
132 instance Ord Pos where
133 compare = compare `on` posAncestors
134 instance Default Pos where
135 def = Pos mempty mempty mempty
137 -- *** Type 'PosPath'
138 type PosPath = Seq (XmlName,Rank)
144 type Words = [WordOrSpace]
146 -- **** Type 'WordOrSpace'
150 deriving (Eq,Ord,Show)
153 type Aliases = [Words]
156 type Terms = [Aliases]
164 , attrs :: CommonAttrs
168 , attrs :: CommonAttrs
172 , attrs :: CommonAttrs
176 , attrs :: CommonAttrs
177 , refs :: [Reference]
179 | Artwork { pos :: Pos
180 , attrs :: CommonAttrs
186 -- * Type 'CommonAttrs'
200 type Blocks = [Block]
208 type Para = Seq Lines
211 type Lines = Tree LineKey LineValue
226 | Iref {anchor :: Maybe Anchor, term :: Words}
238 -- ** Type 'LineValue'
245 newtype Title = Title { unTitle :: Para }
246 deriving (Eq,Show,Default)
260 instance Default Address where
277 instance Default Include where
282 -- * Type 'Reference'
288 reference :: Ident -> Reference
294 instance Default Reference where
303 instance Default Entity where
308 instance Semigroup Entity where
315 , month :: Maybe Nat1
318 instance Default Date where
321 , month = Just (Nat1 01)
322 , day = Just (Nat1 01)
324 instance Semigroup Date where
335 instance Default Link where
348 instance Default Alias where
359 instance Default Serie where