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)
65 instance Default Document where
73 instance Default Head where
82 , authors :: [] Entity
83 , editor :: Maybe Entity
89 , includes :: [] Include
91 instance Default About where
103 instance Semigroup About where
105 { titles = titles x <> titles y
106 , authors = authors x <> authors y
107 , editor = editor x <> editor y
108 , date = date x <> date y
109 , version = version x <> version y
110 , keywords = keywords x <> keywords y
111 , links = links x <> links y
112 , series = series x <> series y
113 , includes = includes x <> includes y
118 = Para { attrs :: CommonAttrs
119 , para :: Horizontals
121 | OL { attrs :: CommonAttrs
122 , items :: [] Verticals
124 | UL { attrs :: CommonAttrs
125 , items :: [] Verticals
127 | RL { attrs :: CommonAttrs
128 , refs :: [] Reference
130 | ToC { attrs :: CommonAttrs
133 | ToF { attrs :: CommonAttrs
136 | Index { attrs :: CommonAttrs
138 | Figure { attrs :: CommonAttrs
143 | Artwork { attrs :: CommonAttrs
146 | Section { attrs :: CommonAttrs
154 -- * Type 'CommonAttrs'
161 -- * Type 'Verticals'
162 type Verticals = [] Vertical
169 -- * Type 'Horizontal'
182 | Eref {href :: URL , text :: Horizontals}
183 | Iref {to :: Ident, text :: Horizontals}
184 | Ref {to :: Ident, text :: Horizontals}
185 | Rref {to :: Ident, text :: Horizontals}
189 -- * Type 'Horizontals'
190 type Horizontals = [] Horizontal
193 newtype Ident = Ident Text
194 deriving (Eq,Show,Default,IsString)
197 newtype Title = Title Horizontals
198 deriving (Eq,Show,Default)
201 newtype URL = URL Text
202 deriving (Eq,Show,Default)
205 newtype Path = Path Text
206 deriving (Eq,Show,Default)
221 instance Default Address where
238 instance Default Include where
243 -- * Type 'Reference'
250 reference :: Ident -> Reference
257 instance Default Reference where
266 instance Default Entity where
271 instance Semigroup Entity where
278 , month :: Maybe Nat1
281 instance Default Date where
284 , month = Just (Nat1 01)
285 , day = Just (Nat1 01)
287 instance Semigroup Date where
296 , body :: Horizontals
298 instance Default Link where
311 instance Default Alias where
328 instance Default Serie where