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
54 , editor :: Maybe Entity
60 , includes :: [Include]
62 instance Default About where
74 instance Semigroup About where
76 { titles = titles x <> titles y
77 , authors = authors x <> authors y
78 , editor = editor x <> editor y
79 , date = date x <> date y
80 , version = version x <> version y
81 , keywords = keywords x <> keywords y
82 , links = links x <> links y
83 , series = series x <> series y
84 , includes = includes x <> includes y
88 type Body = Trees BodyKey BodyValue
92 = Section { pos :: Pos
93 , attrs :: CommonAttrs
99 -- ** Type 'BodyValue'
102 , attrs :: CommonAttrs
106 , attrs :: CommonAttrs
109 | Figure { pos :: Pos
110 , attrs :: CommonAttrs
116 , attrs :: CommonAttrs
125 { posAncestors :: PosPath
126 , posAncestorsWithFigureNames :: PosPath
127 , posPrecedingsSiblings :: Map XmlName Rank
129 instance Ord Pos where
130 compare = compare `on` posAncestors
131 instance Default Pos where
132 def = Pos mempty mempty mempty
134 -- *** Type 'PosPath'
135 type PosPath = Seq (XmlName,Rank)
141 type Words = [WordOrSpace]
143 -- **** Type 'WordOrSpace'
147 deriving (Eq,Ord,Show)
150 type Aliases = [Words]
153 type Terms = [Aliases]
161 , attrs :: CommonAttrs
165 , attrs :: CommonAttrs
169 , attrs :: CommonAttrs
173 , attrs :: CommonAttrs
174 , refs :: [Reference]
176 | Artwork { pos :: Pos
177 , attrs :: CommonAttrs
183 -- * Type 'CommonAttrs'
197 type Blocks = [Block]
205 type Para = Seq Lines
208 type Lines = Tree LineKey LineValue
223 | Iref {count :: Int, term :: Words}
228 -- ** Type 'LineValue'
235 newtype Title = Title { unTitle :: Para }
236 deriving (Eq,Show,Default)
250 instance Default Address where
267 instance Default Include where
272 -- * Type 'Reference'
279 reference :: Ident -> Reference
286 instance Default Reference where
295 instance Default Entity where
300 instance Semigroup Entity where
307 , month :: Maybe Nat1
310 instance Default Date where
313 , month = Just (Nat1 01)
314 , day = Just (Nat1 01)
316 instance Semigroup Date where
327 instance Default Link where
340 instance Default Alias where
351 instance Default Serie where