module Language.Ltml.AST.Table
( Table (..)
, Row (..)
, Cell (..)
)
where
import Language.Lsd.AST.Type.Table (CellFormat)
import Language.Ltml.AST.Text (TableTextTree)
type ColumnProps = Maybe [Int]
data Table = Table ColumnProps [Row]
instance Show Table where
show :: Table -> String
show (Table ColumnProps
_ [Row]
rows) = [String] -> String
unlines ([String] -> String) -> [String] -> String
forall a b. (a -> b) -> a -> b
$ (Row -> String) -> [Row] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map Row -> String
forall a. Show a => a -> String
show [Row]
rows
newtype Row = Row [Cell]
deriving (Int -> Row -> ShowS
[Row] -> ShowS
Row -> String
(Int -> Row -> ShowS)
-> (Row -> String) -> ([Row] -> ShowS) -> Show Row
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Row -> ShowS
showsPrec :: Int -> Row -> ShowS
$cshow :: Row -> String
show :: Row -> String
$cshowList :: [Row] -> ShowS
showList :: [Row] -> ShowS
Show)
type Width = Int
type Height = Int
data Cell
= Cell CellFormat [TableTextTree] Width Height
| VSpannedCell Int
| HSpannedCell
deriving (Int -> Cell -> ShowS
[Cell] -> ShowS
Cell -> String
(Int -> Cell -> ShowS)
-> (Cell -> String) -> ([Cell] -> ShowS) -> Show Cell
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Cell -> ShowS
showsPrec :: Int -> Cell -> ShowS
$cshow :: Cell -> String
show :: Cell -> String
$cshowList :: [Cell] -> ShowS
showList :: [Cell] -> ShowS
Show)
instance Eq Cell where
(Cell {}) == :: Cell -> Cell -> Bool
== (Cell {}) = Bool
True
VSpannedCell {} == VSpannedCell {} = Bool
True
HSpannedCell {} == HSpannedCell {} = Bool
True
Cell
_ == Cell
_ = Bool
False