]> Git — Sourcephile - doclang.git/blob - Hdoc/TCT/Cell.hs
XML: use symantic-xml
[doclang.git] / Hdoc / TCT / Cell.hs
1 {-# LANGUAGE FlexibleInstances #-}
2 module Hdoc.TCT.Cell
3 ( module Hdoc.TCT.Cell
4 , XML.FileRange(..)
5 , XML.FilePos(..)
6 , XML.NoSource(..)
7 , XML.Sourced(..)
8 ) where
9
10 import Data.List.NonEmpty (NonEmpty(..))
11 import Prelude (Int)
12 import qualified Language.Symantic.XML as XML
13
14 -- * Type 'Pos'
15 -- | Absolute text file position.
16 type Pos = XML.FilePos
17 {-
18 instance Semigroup Pos where
19 Pos lx cx <> Pos ly cy =
20 Pos (lx+ly) (cx+cy)
21 instance Monoid Pos where
22 mempty = Pos 0 0
23 mappend = (<>)
24 -}
25
26 pos1 :: Pos
27 pos1 = XML.filePos1
28
29 -- ** Type 'LineNum'
30 type LineNum = Int
31
32 -- ** Type 'ColNum'
33 type ColNum = Int
34
35 -- * Type 'Cell'
36 type Cell = XML.Sourced Location
37 {-
38 instance (FromPad a, Semigroup a, Monoid a) => Monoid (Cell a) where
39 mempty = cell0 mempty
40 mappend = (<>)
41 -}
42
43 cell0 :: a -> Cell a
44 cell0 = XML.Sourced (XML.FileRange "" filePos0 filePos0 :| [])
45 where filePos0 = XML.FilePos 0 0
46
47 -- ** Type 'Span'
48 type Span = XML.FileRange
49
50 -- ** Type 'Location'
51 type Location = XML.FileSource