-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Parser for reStructuredText-style grid tables.
--   
--   Provides a parser for plain-text representations of tables. This
--   package supports table headers, cells spanning multiple columns or
--   rows, as well as a way to specfiy column alignments.
@package gridtables
@version 0.1.1.0

-- | Grid table representation based on arrays.
module Text.GridTable.ArrayTable

-- | Table representation based on an array; cells are placed on a grid,
--   with indices spanned by other cells containing placeholder cells that
--   point to the spanning cell.
data ArrayTable a
ArrayTable :: Array CellIndex (GridCell a) -> Maybe RowIndex -> Maybe RowIndex -> Array ColIndex (Alignment, Int) -> ArrayTable a
[arrayTableCells] :: ArrayTable a -> Array CellIndex (GridCell a)
[arrayTableHead] :: ArrayTable a -> Maybe RowIndex
[arrayTableFoot] :: ArrayTable a -> Maybe RowIndex
[arrayTableColSpecs] :: ArrayTable a -> Array ColIndex (Alignment, Int)

-- | A grid cell contains either a real table cell, or is the continuation
--   of a column or row-spanning cell. In the latter case, the index of the
--   continued cell is provided.
data GridCell a
ContentCell :: RowSpan -> ColSpan -> a -> GridCell a
ContinuationCell :: CellIndex -> GridCell a

-- | The number of rows spanned by a cell.
newtype RowSpan
RowSpan :: Int -> RowSpan

-- | The number of columns spanned by a cell.
newtype ColSpan
ColSpan :: Int -> ColSpan

-- | Index to a cell in a table part.
type CellIndex = (RowIndex, ColIndex)

-- | Row index in a table array.
newtype RowIndex
RowIndex :: Int -> RowIndex
[fromRowIndex] :: RowIndex -> Int

-- | Column index in a table array.
newtype ColIndex
ColIndex :: Int -> ColIndex
[fromColIndex] :: ColIndex -> Int

-- | Cell alignment
data Alignment
AlignDefault :: Alignment
AlignLeft :: Alignment
AlignCenter :: Alignment
AlignRight :: Alignment

-- | Apply a function to all cell contents in a grid table.
mapCells :: (a -> b) -> ArrayTable a -> ArrayTable b
instance GHC.Internal.Enum.Enum Text.GridTable.ArrayTable.Alignment
instance GHC.Internal.Enum.Enum Text.GridTable.ArrayTable.ColIndex
instance GHC.Internal.Enum.Enum Text.GridTable.ArrayTable.ColSpan
instance GHC.Internal.Enum.Enum Text.GridTable.ArrayTable.RowIndex
instance GHC.Internal.Enum.Enum Text.GridTable.ArrayTable.RowSpan
instance GHC.Classes.Eq Text.GridTable.ArrayTable.Alignment
instance GHC.Classes.Eq a => GHC.Classes.Eq (Text.GridTable.ArrayTable.ArrayTable a)
instance GHC.Classes.Eq Text.GridTable.ArrayTable.ColIndex
instance GHC.Classes.Eq Text.GridTable.ArrayTable.ColSpan
instance GHC.Classes.Eq a => GHC.Classes.Eq (Text.GridTable.ArrayTable.GridCell a)
instance GHC.Classes.Eq Text.GridTable.ArrayTable.RowIndex
instance GHC.Classes.Eq Text.GridTable.ArrayTable.RowSpan
instance GHC.Internal.Ix.Ix Text.GridTable.ArrayTable.ColIndex
instance GHC.Internal.Ix.Ix Text.GridTable.ArrayTable.RowIndex
instance GHC.Internal.Num.Num Text.GridTable.ArrayTable.ColIndex
instance GHC.Internal.Num.Num Text.GridTable.ArrayTable.ColSpan
instance GHC.Internal.Num.Num Text.GridTable.ArrayTable.RowIndex
instance GHC.Internal.Num.Num Text.GridTable.ArrayTable.RowSpan
instance GHC.Classes.Ord Text.GridTable.ArrayTable.Alignment
instance GHC.Classes.Ord Text.GridTable.ArrayTable.ColIndex
instance GHC.Classes.Ord Text.GridTable.ArrayTable.ColSpan
instance GHC.Classes.Ord Text.GridTable.ArrayTable.RowIndex
instance GHC.Classes.Ord Text.GridTable.ArrayTable.RowSpan
instance GHC.Internal.Read.Read Text.GridTable.ArrayTable.Alignment
instance GHC.Internal.Read.Read Text.GridTable.ArrayTable.ColSpan
instance GHC.Internal.Read.Read Text.GridTable.ArrayTable.RowSpan
instance GHC.Internal.Show.Show Text.GridTable.ArrayTable.Alignment
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Text.GridTable.ArrayTable.ArrayTable a)
instance GHC.Internal.Show.Show Text.GridTable.ArrayTable.ColIndex
instance GHC.Internal.Show.Show Text.GridTable.ArrayTable.ColSpan
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Text.GridTable.ArrayTable.GridCell a)
instance GHC.Internal.Show.Show Text.GridTable.ArrayTable.RowIndex
instance GHC.Internal.Show.Show Text.GridTable.ArrayTable.RowSpan

-- | Trace cells of a grid table.
module Text.GridTable.Trace

-- | Traces out the cells in the given lines and converts them to a table
--   containing the bare cell lines.
traceLines :: [Text] -> Maybe (ArrayTable [Text])

-- | Info on the grid. Used to keep track of information collected while
--   tracing a character grid. The set of cells is used as a kind of queue
--   during parsing, while the other data is required to assemble the final
--   table.
data TraceInfo
TraceInfo :: Set CharRow -> Set CharCol -> Set CharIndex -> Set CellTrace -> TraceInfo
[gridRowSeps] :: TraceInfo -> Set CharRow
[gridColSeps] :: TraceInfo -> Set CharCol
[gridCorners] :: TraceInfo -> Set CharIndex
[gridCells] :: TraceInfo -> Set CellTrace

-- | Initial tracing info.
initialTraceInfo :: TraceInfo

-- | Create a final grid table from line scanning data.
tableFromTraceInfo :: TraceInfo -> [PartSeparator] -> Maybe [ColSpec] -> ArrayTable [Text]
instance GHC.Internal.Enum.Enum Text.GridTable.Trace.CharCol
instance GHC.Internal.Enum.Enum Text.GridTable.Trace.CharRow
instance GHC.Classes.Eq Text.GridTable.Trace.CellTrace
instance GHC.Classes.Eq Text.GridTable.Trace.CharCol
instance GHC.Classes.Eq Text.GridTable.Trace.CharRow
instance GHC.Classes.Eq Text.GridTable.Trace.GChar
instance GHC.Internal.Ix.Ix Text.GridTable.Trace.CharCol
instance GHC.Internal.Ix.Ix Text.GridTable.Trace.CharRow
instance GHC.Internal.Num.Num Text.GridTable.Trace.CharCol
instance GHC.Internal.Num.Num Text.GridTable.Trace.CharRow
instance GHC.Classes.Ord Text.GridTable.Trace.CellTrace
instance GHC.Classes.Ord Text.GridTable.Trace.CharCol
instance GHC.Classes.Ord Text.GridTable.Trace.CharRow
instance GHC.Internal.Show.Show Text.GridTable.Trace.CellTrace
instance GHC.Internal.Show.Show Text.GridTable.Trace.CharCol
instance GHC.Internal.Show.Show Text.GridTable.Trace.CharRow

-- | Parse reStructuredText-style grid tables.
module Text.GridTable.Parse

-- | Parses a grid table.
gridTable :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m (ArrayTable [Text])

-- | Parses a line that's part of a table. The line must start with either
--   a plus + or a pipe |.
tableLine :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m Text

-- | Parse reStructuredText-style grid tables.
module Text.GridTable

-- | Parses a grid table.
gridTable :: forall s (m :: Type -> Type) u. Stream s m Char => ParsecT s u m (ArrayTable [Text])

-- | Raw grid table cell
data Cell a
Cell :: a -> RowSpan -> ColSpan -> Cell a
[cellContent] :: Cell a -> a
[cellRowSpan] :: Cell a -> RowSpan
[cellColSpan] :: Cell a -> ColSpan

-- | Returns the rows of a grid table as lists of simple cells.
rows :: ArrayTable a -> [[Cell a]]
instance GHC.Classes.Eq a => GHC.Classes.Eq (Text.GridTable.Cell a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Text.GridTable.Cell a)
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Text.GridTable.Cell a)
