1 {-# LANGUAGE DisambiguateRecordFields #-}
2 {-# LANGUAGE DuplicateRecordFields #-}
3 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
4 {-# LANGUAGE NamedFieldPuns #-}
5 {-# LANGUAGE OverloadedStrings #-}
6 module Language.DTC.Document where
8 import Control.Applicative (Applicative(..))
11 import Data.Maybe (Maybe(..))
13 import Data.Semigroup (Semigroup(..))
14 import Data.Sequence (Seq)
15 import Data.String (IsString(..))
16 import Data.Text (Text)
17 import Text.Show (Show)
18 import qualified Data.Sequence as Seq
19 import Language.TCT.Write.XML (XmlPos(..))
24 instance Default Text where
26 instance Default (Maybe a) where
28 instance Default [a] where
30 instance Default (Seq a) where
35 = MayText { unMayText :: Text }
36 deriving (Eq,Show,Default)
37 instance Semigroup MayText where
42 whenMayText :: Applicative m => MayText -> (MayText -> m ()) -> m ()
43 whenMayText (MayText "") _f = pure ()
48 deriving (Eq, Ord, Show)
51 newtype Nat1 = Nat1 Int
52 deriving (Eq, Ord, Show)
60 instance Default Document where
71 instance Default Head where
81 , editor :: Maybe Entity
87 , includes :: [Include]
89 instance Default About where
101 instance Semigroup About where
103 { titles = titles x <> titles y
104 , authors = authors x <> authors y
105 , editor = editor x <> editor y
106 , date = date x <> date y
107 , version = version x <> version y
108 , keywords = keywords x <> keywords y
109 , links = links x <> links y
110 , series = series x <> series y
111 , includes = includes x <> includes y
116 = Section { attrs :: CommonAttrs
122 | Verticals [Vertical]
127 = Para { attrs :: CommonAttrs
128 , horis :: Horizontals
131 | OL { attrs :: CommonAttrs
132 , items :: [Verticals]
135 | UL { attrs :: CommonAttrs
136 , items :: [Verticals]
139 | RL { attrs :: CommonAttrs
140 , refs :: [Reference]
143 | ToC { attrs :: CommonAttrs
147 | ToF { attrs :: CommonAttrs
151 | Index { attrs :: CommonAttrs
154 | Figure { type_ :: Text
155 , attrs :: CommonAttrs
160 | Artwork { attrs :: CommonAttrs
167 -- * Type 'CommonAttrs'
180 -- * Type 'Verticals'
181 type Verticals = [Vertical]
188 -- * Type 'Horizontal'
201 | Eref {href :: URL , text :: Horizontals}
202 | Iref {to :: Ident, text :: Horizontals}
203 | Ref {to :: Ident, text :: Horizontals}
204 | Rref {to :: Ident, text :: Horizontals}
208 -- * Type 'Horizontals'
209 type Horizontals = [Horizontal]
212 newtype Ident = Ident { unIdent :: Text }
213 deriving (Eq,Show,Default,IsString)
216 newtype Title = Title { unTitle :: Horizontals }
217 deriving (Eq,Show,Default)
220 newtype URL = URL Text
221 deriving (Eq,Show,Default)
224 newtype Path = Path Text
225 deriving (Eq,Show,Default)
240 instance Default Address where
257 instance Default Include where
262 -- * Type 'Reference'
269 reference :: Ident -> Reference
276 instance Default Reference where
285 instance Default Entity where
290 instance Semigroup Entity where
297 , month :: Maybe Nat1
300 instance Default Date where
303 , month = Just (Nat1 01)
304 , day = Just (Nat1 01)
306 instance Semigroup Date where
315 , body :: Horizontals
317 instance Default Link where
330 instance Default Alias where
341 instance Default Serie where