{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
module Errata.Types
(
Line
, Column
, Header
, Body
, Label
, Errata (..)
, Block (..)
, Pointer (..)
, pointerColumns
, pointerData
, Style (..)
, PointerStyle (..)
) where
import qualified Data.Text as T
type Line = Int
type Column = Int
type = T.Text
type Body = T.Text
type Label = T.Text
data Errata = Errata
{ :: Maybe Header
, Errata -> [Block]
errataBlocks :: [Block]
, Errata -> Maybe Header
errataBody :: Maybe Body
}
deriving (Int -> Errata -> ShowS
[Errata] -> ShowS
Errata -> String
(Int -> Errata -> ShowS)
-> (Errata -> String) -> ([Errata] -> ShowS) -> Show Errata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Errata] -> ShowS
$cshowList :: [Errata] -> ShowS
show :: Errata -> String
$cshow :: Errata -> String
showsPrec :: Int -> Errata -> ShowS
$cshowsPrec :: Int -> Errata -> ShowS
Show)
data Block = Block
{ Block -> Style
blockStyle :: Style
, Block -> (String, Int, Int)
blockLocation :: (FilePath, Line, Column)
, :: Maybe Header
, Block -> [Pointer]
blockPointers :: [Pointer]
, Block -> Maybe Header
blockBody :: Maybe Body
}
deriving (Int -> Block -> ShowS
[Block] -> ShowS
Block -> String
(Int -> Block -> ShowS)
-> (Block -> String) -> ([Block] -> ShowS) -> Show Block
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Block] -> ShowS
$cshowList :: [Block] -> ShowS
show :: Block -> String
$cshow :: Block -> String
showsPrec :: Int -> Block -> ShowS
$cshowsPrec :: Int -> Block -> ShowS
Show)
data Pointer = Pointer
{ Pointer -> Int
pointerLine :: Line
, Pointer -> Int
pointerColStart :: Column
, Pointer -> Int
pointerColEnd :: Column
, Pointer -> Bool
pointerConnect :: Bool
, Pointer -> Maybe Header
pointerLabel :: Maybe Label
, Pointer -> PointerStyle
pointerStyle :: PointerStyle
}
deriving (Int -> Pointer -> ShowS
[Pointer] -> ShowS
Pointer -> String
(Int -> Pointer -> ShowS)
-> (Pointer -> String) -> ([Pointer] -> ShowS) -> Show Pointer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Pointer] -> ShowS
$cshowList :: [Pointer] -> ShowS
show :: Pointer -> String
$cshow :: Pointer -> String
showsPrec :: Int -> Pointer -> ShowS
$cshowsPrec :: Int -> Pointer -> ShowS
Show)
pointerColumns :: Pointer -> (Column, Column)
pointerColumns :: Pointer -> (Int, Int)
pointerColumns (Pointer {Bool
Int
Maybe Header
PointerStyle
pointerStyle :: PointerStyle
pointerLabel :: Maybe Header
pointerConnect :: Bool
pointerColEnd :: Int
pointerColStart :: Int
pointerLine :: Int
pointerStyle :: Pointer -> PointerStyle
pointerLabel :: Pointer -> Maybe Header
pointerConnect :: Pointer -> Bool
pointerColEnd :: Pointer -> Int
pointerColStart :: Pointer -> Int
pointerLine :: Pointer -> Int
..}) = (Int
pointerColStart, Int
pointerColEnd)
pointerData :: Pointer -> (Line, Column, Column, Bool, Maybe Label)
pointerData :: Pointer -> (Int, Int, Int, Bool, Maybe Header)
pointerData (Pointer {Bool
Int
Maybe Header
PointerStyle
pointerStyle :: PointerStyle
pointerLabel :: Maybe Header
pointerConnect :: Bool
pointerColEnd :: Int
pointerColStart :: Int
pointerLine :: Int
pointerStyle :: Pointer -> PointerStyle
pointerLabel :: Pointer -> Maybe Header
pointerConnect :: Pointer -> Bool
pointerColEnd :: Pointer -> Int
pointerColStart :: Pointer -> Int
pointerLine :: Pointer -> Int
..}) = (Int
pointerLine, Int
pointerColStart, Int
pointerColEnd, Bool
pointerConnect, Maybe Header
pointerLabel)
data Style = Style
{ Style -> (String, Int, Int) -> Header
styleLocation :: (FilePath, Line, Column) -> T.Text
, Style -> Int -> Header
styleNumber :: Line -> T.Text
, Style -> [(PointerStyle, (Int, Int))] -> Header -> Header
styleLine :: [(PointerStyle, (Column, Column))] -> T.Text -> T.Text
, Style -> Header
styleEllipsis :: T.Text
, Style -> Header
styleLinePrefix :: T.Text
, Style -> Header
styleVertical :: T.Text
, Style -> Header
styleHorizontal :: T.Text
, Style -> Header
styleDownRight :: T.Text
, Style -> Header
styleUpRight :: T.Text
, Style -> Header
styleUpDownRight :: T.Text
, Style -> Int
styleTabWidth :: Int
, :: Int
, :: Int
, Style -> Bool
stylePaddingTop :: Bool
, Style -> Bool
stylePaddingBottom :: Bool
, Style -> Bool
styleEnableDecorations :: Bool
, Style -> Bool
styleEnableLinePrefix :: Bool
}
instance Show Style where
show :: Style -> String
show (Style {Bool
Int
Header
Int -> Header
[(PointerStyle, (Int, Int))] -> Header -> Header
(String, Int, Int) -> Header
styleEnableLinePrefix :: Bool
styleEnableDecorations :: Bool
stylePaddingBottom :: Bool
stylePaddingTop :: Bool
styleExtraLinesBefore :: Int
styleExtraLinesAfter :: Int
styleTabWidth :: Int
styleUpDownRight :: Header
styleUpRight :: Header
styleDownRight :: Header
styleHorizontal :: Header
styleVertical :: Header
styleLinePrefix :: Header
styleEllipsis :: Header
styleLine :: [(PointerStyle, (Int, Int))] -> Header -> Header
styleNumber :: Int -> Header
styleLocation :: (String, Int, Int) -> Header
styleEnableLinePrefix :: Style -> Bool
styleEnableDecorations :: Style -> Bool
stylePaddingBottom :: Style -> Bool
stylePaddingTop :: Style -> Bool
styleExtraLinesBefore :: Style -> Int
styleExtraLinesAfter :: Style -> Int
styleTabWidth :: Style -> Int
styleUpDownRight :: Style -> Header
styleUpRight :: Style -> Header
styleDownRight :: Style -> Header
styleHorizontal :: Style -> Header
styleVertical :: Style -> Header
styleLinePrefix :: Style -> Header
styleEllipsis :: Style -> Header
styleLine :: Style -> [(PointerStyle, (Int, Int))] -> Header -> Header
styleNumber :: Style -> Int -> Header
styleLocation :: Style -> (String, Int, Int) -> Header
..}) = [String] -> String
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
[ String
"Style {"
, String
"styleLocation = ", Header -> String
forall a. Show a => a -> String
show (Header -> String) -> Header -> String
forall a b. (a -> b) -> a -> b
$ (String, Int, Int) -> Header
styleLocation (String
"file", Int
1, Int
1)
, String
", styleNumber = ", Header -> String
forall a. Show a => a -> String
show (Header -> String) -> Header -> String
forall a b. (a -> b) -> a -> b
$ Int -> Header
styleNumber Int
3
, String
", styleLine = ", Header -> String
forall a. Show a => a -> String
show (Header -> String) -> Header -> String
forall a b. (a -> b) -> a -> b
$ [(PointerStyle, (Int, Int))] -> Header -> Header
styleLine [(PointerStyle
basicPointer, (Int
1, Int
5))] Header
"text"
, String
", styleEllipsis = ", Header -> String
forall a. Show a => a -> String
show Header
styleEllipsis
, String
", styleLinePrefix = ", Header -> String
forall a. Show a => a -> String
show Header
styleLinePrefix
, String
", styleVertical = ", Header -> String
forall a. Show a => a -> String
show Header
styleVertical
, String
", styleHorizontal = ", Header -> String
forall a. Show a => a -> String
show Header
styleHorizontal
, String
", styleDownRight = ", Header -> String
forall a. Show a => a -> String
show Header
styleDownRight
, String
", styleUpRight = ", Header -> String
forall a. Show a => a -> String
show Header
styleUpRight
, String
", styleUpDownRight = ", Header -> String
forall a. Show a => a -> String
show Header
styleUpDownRight
, String
", styleTabWidth = ", Int -> String
forall a. Show a => a -> String
show Int
styleTabWidth
, String
", styleExtraLinesAfter = ", Int -> String
forall a. Show a => a -> String
show Int
styleExtraLinesAfter
, String
", styleExtraLinesBefore = ", Int -> String
forall a. Show a => a -> String
show Int
styleExtraLinesBefore
, String
", stylePaddingTop = ", Bool -> String
forall a. Show a => a -> String
show Bool
stylePaddingTop
, String
", stylePaddingBottom = ", Bool -> String
forall a. Show a => a -> String
show Bool
stylePaddingBottom
, String
", styleEnableDecorations = ", Bool -> String
forall a. Show a => a -> String
show Bool
styleEnableDecorations
, String
", styleEnableLinePrefix = ", Bool -> String
forall a. Show a => a -> String
show Bool
styleEnableLinePrefix
, String
"}"
]
where
basicPointer :: PointerStyle
basicPointer = PointerStyle
{ styleHighlight :: Header -> Header
styleHighlight = Header -> Header
forall a. a -> a
id
, styleUnderline :: Header
styleUnderline = Header
"^"
, styleHook :: Header
styleHook = Header
"|"
, styleConnector :: Header
styleConnector = Header
"|"
, styleEnableHook :: Bool
styleEnableHook = Bool
True
}
data PointerStyle = PointerStyle
{ PointerStyle -> Header -> Header
styleHighlight :: T.Text -> T.Text
, PointerStyle -> Header
styleUnderline :: T.Text
, PointerStyle -> Header
styleHook :: T.Text
, PointerStyle -> Header
styleConnector :: T.Text
, PointerStyle -> Bool
styleEnableHook :: Bool
}
instance Show PointerStyle where
show :: PointerStyle -> String
show (PointerStyle {Bool
Header
Header -> Header
styleEnableHook :: Bool
styleConnector :: Header
styleHook :: Header
styleUnderline :: Header
styleHighlight :: Header -> Header
styleEnableHook :: PointerStyle -> Bool
styleConnector :: PointerStyle -> Header
styleHook :: PointerStyle -> Header
styleUnderline :: PointerStyle -> Header
styleHighlight :: PointerStyle -> Header -> Header
..}) = [String] -> String
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
[ String
"PointerStyle {"
, String
"styleHighlight = ", Header -> String
forall a. Show a => a -> String
show (Header -> String) -> Header -> String
forall a b. (a -> b) -> a -> b
$ Header -> Header
styleHighlight Header
"text"
, String
", styleUnderline = ", Header -> String
forall a. Show a => a -> String
show Header
styleUnderline
, String
", styleHook = ", Header -> String
forall a. Show a => a -> String
show Header
styleHook
, String
", styleConnector = ", Header -> String
forall a. Show a => a -> String
show Header
styleConnector
, String
", styleEnableHook = ", Bool -> String
forall a. Show a => a -> String
show Bool
styleEnableHook
, String
"}"
]