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
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 = Section { attrs :: CommonAttrs
120 | Verticals [Vertical]
125 = Para { attrs :: CommonAttrs
126 , horis :: Horizontals
128 | OL { attrs :: CommonAttrs
129 , items :: [Verticals]
131 | UL { attrs :: CommonAttrs
132 , items :: [Verticals]
134 | RL { attrs :: CommonAttrs
135 , refs :: [Reference]
137 | ToC { attrs :: CommonAttrs
140 | ToF { attrs :: CommonAttrs
143 | Index { attrs :: CommonAttrs
145 | Figure { type_ :: Text
146 , attrs :: CommonAttrs
150 | Artwork { attrs :: CommonAttrs
156 -- * Type 'CommonAttrs'
163 -- * Type 'Verticals'
164 type Verticals = [Vertical]
171 -- * Type 'Horizontal'
184 | Eref {href :: URL , text :: Horizontals}
185 | Iref {to :: Ident, text :: Horizontals}
186 | Ref {to :: Ident, text :: Horizontals}
187 | Rref {to :: Ident, text :: Horizontals}
191 -- * Type 'Horizontals'
192 type Horizontals = [Horizontal]
195 newtype Ident = Ident { unIdent :: Text }
196 deriving (Eq,Show,Default,IsString)
199 newtype Title = Title { unTitle :: Horizontals }
200 deriving (Eq,Show,Default)
203 newtype URL = URL Text
204 deriving (Eq,Show,Default)
207 newtype Path = Path Text
208 deriving (Eq,Show,Default)
223 instance Default Address where
240 instance Default Include where
245 -- * Type 'Reference'
252 reference :: Ident -> Reference
259 instance Default Reference where
268 instance Default Entity where
273 instance Semigroup Entity where
280 , month :: Maybe Nat1
283 instance Default Date where
286 , month = Just (Nat1 01)
287 , day = Just (Nat1 01)
289 instance Semigroup Date where
298 , body :: Horizontals
300 instance Default Link where
313 instance Default Alias where
324 instance Default Serie where