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
23 instance Default Text where
25 instance Default (Maybe a) where
27 instance Default [a] where
29 instance Default (Seq a) where
34 = MayText { unMayText :: Text }
35 deriving (Eq,Show,Default)
36 instance Semigroup MayText where
41 whenMayText :: Applicative m => MayText -> (MayText -> m ()) -> m ()
42 whenMayText (MayText "") _f = pure ()
47 deriving (Eq, Ord, Show)
50 newtype Nat1 = Nat1 Int
51 deriving (Eq, Ord, Show)
59 instance Default Document where
70 instance Default Head where
79 , authors :: [] Entity
80 , editor :: Maybe Entity
86 , includes :: [] Include
88 instance Default About where
100 instance Semigroup About where
102 { titles = titles x <> titles y
103 , authors = authors x <> authors y
104 , editor = editor x <> editor y
105 , date = date x <> date y
106 , version = version x <> version y
107 , keywords = keywords x <> keywords y
108 , links = links x <> links y
109 , series = series x <> series y
110 , includes = includes x <> includes y
115 = Para { attrs :: CommonAttrs
116 , para :: Horizontals
118 | OL { attrs :: CommonAttrs
119 , items :: [] Verticals
121 | UL { attrs :: CommonAttrs
122 , items :: [] Verticals
124 | RL { attrs :: CommonAttrs
125 , refs :: [] Reference
127 | ToC { attrs :: CommonAttrs
130 | ToF { attrs :: CommonAttrs
133 | Index { attrs :: CommonAttrs
135 | Figure { attrs :: CommonAttrs
140 | Artwork { attrs :: CommonAttrs
143 | Section { attrs :: CommonAttrs
151 -- * Type 'CommonAttrs'
158 -- * Type 'Verticals'
159 type Verticals = [] Vertical
166 -- * Type 'Horizontal'
179 | Eref {href :: URL , text :: Horizontals}
180 | Iref {to :: Ident, text :: Horizontals}
181 | Ref {to :: Ident, text :: Horizontals}
182 | Rref {to :: Ident, text :: Horizontals}
186 -- * Type 'Horizontals'
187 type Horizontals = [] Horizontal
190 newtype Ident = Ident Text
191 deriving (Eq,Show,Default,IsString)
194 newtype Title = Title Horizontals
195 deriving (Eq,Show,Default)
198 newtype URL = URL Text
199 deriving (Eq,Show,Default)
202 newtype Path = Path Text
203 deriving (Eq,Show,Default)
218 instance Default Address where
235 instance Default Include where
240 -- * Type 'Reference'
247 reference :: Ident -> Reference
254 instance Default Reference where
263 instance Default Entity where
268 instance Semigroup Entity where
275 , month :: Maybe Nat1
278 instance Default Date where
281 , month = Just (Nat1 01)
282 , day = Just (Nat1 01)
284 instance Semigroup Date where
293 , body :: Horizontals
295 instance Default Link where
308 instance Default Alias where
319 instance Default Serie where