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.TreeSeq.Strict (Tree(..), Trees)
22 import Text.Show (Show)
23 import qualified Data.Text.Lazy as TL
33 instance Default Document where
44 instance Default Head where
55 , editor :: Maybe Entity
58 , keywords :: [TL.Text]
61 , includes :: [Include]
63 instance Default About where
76 instance Semigroup About where
78 { titles = titles x <> titles y
79 , url = url (x::About) <> url (y::About)
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 BodyNode
95 = Section { pos :: Pos
96 , attrs :: CommonAttrs
101 , attrs :: CommonAttrs
105 , attrs :: CommonAttrs
108 | Figure { pos :: Pos
109 , attrs :: CommonAttrs
111 , mayTitle :: Maybe Title
115 , attrs :: CommonAttrs
118 | References { pos :: Pos
119 , attrs :: CommonAttrs
120 , refs :: [Reference]
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
175 | Artwork { pos :: Pos
176 , attrs :: CommonAttrs
181 , attrs :: CommonAttrs
188 -- * Type 'CommonAttrs'
192 , classes :: [TL.Text]
196 type Blocks = [Block]
199 type Para = Seq Lines
202 type Lines = Tree LineNode
204 -- ** Type 'LineNode'
210 | Note {number :: Maybe Nat1}
217 | Iref {anchor :: Maybe Anchor, term :: Words}
219 | Rref {anchor :: Maybe Anchor, to :: Ident}
229 } deriving (Eq,Ord,Show)
232 newtype Title = Title { unTitle :: Para }
233 deriving (Eq,Show,Semigroup,Monoid,Default)
248 , org :: Maybe Entity
250 instance Default Entity where
264 instance Semigroup Entity where
272 instance Default Include where
277 -- * Type 'Reference'
283 reference :: Ident -> Reference
289 instance Default Reference where
296 , month :: Maybe Nat1
299 instance Default Date where
302 , month = Just (Nat1 01)
303 , day = Just (Nat1 01)
305 instance Semigroup Date where
316 instance Default Link where
329 instance Default Alias where
340 instance Default Serie where