Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Contains the innards of Rainbox
. You shouldn't need anything
in here. Some functions here are partial or have undefined results
if their inputs don't respect particular invariants.
- data Alignment a
- data Horizontal
- data Vertical
- center :: Alignment a
- centerH :: Alignment Horizontal
- centerV :: Alignment Vertical
- left :: Alignment Vertical
- right :: Alignment Vertical
- top :: Alignment Horizontal
- bottom :: Alignment Horizontal
- newtype Height = Height Int
- newtype Width = Width Int
- class HasHeight a where
- class HasWidth a where
- newtype Core = Core (Either Chunk (Height, Width))
- newtype Rod = Rod (Either (Int, Radiant) Chunk)
- data RodRows
- = RodRowsWithHeight (Seq (Seq Rod))
- | RodRowsNoHeight Int
- rodRowsFromCore :: Radiant -> Core -> RodRows
- chunksFromRodRows :: RodRows -> Seq (Seq Chunk)
- data Payload a = Payload (Alignment a) Radiant (Either RodRows Core)
- addVerticalPadding :: Box Horizontal -> Seq RodRows
- horizontalMerge :: Seq RodRows -> RodRows
- addHorizontalPadding :: Box Vertical -> Seq RodRows
- verticalMerge :: Seq RodRows -> RodRows
- newtype Box a = Box (Seq (Payload a))
- class Orientation a where
- class LeftRight a where
- class UpDown a where
- fromChunk :: Alignment a -> Radiant -> Chunk -> Box a
- blank :: Alignment a -> Radiant -> Height -> Width -> Box a
- wrap :: Orientation a => Alignment b -> Radiant -> Box a -> Box b
- render :: Orientation a => Box a -> Seq Chunk
- data Cell = Cell {}
- separator :: Radiant -> Int -> Cell
- emptyCell :: Cell
- tableByRows :: Seq (Seq Cell) -> Box Vertical
- rowToBoxV :: Box Horizontal -> Box Vertical
- cellToBoxV :: Cell -> (Box Vertical, Alignment Horizontal, Radiant)
- toBoxH :: (Box Vertical, Alignment Horizontal, Radiant) -> Box Horizontal
- addWidthMap :: Seq (Seq (Box Vertical, b, c)) -> (Map Int (Int, Int), Seq (Seq (Box Vertical, b, c)))
- padBoxV :: Map Int (Int, Int) -> Seq (Seq (Box Vertical, a, b)) -> Seq (Seq (Box Vertical, a, b))
- widestCellMap :: Seq (Seq (Box Vertical)) -> Map Int (Int, Int)
- tableByColumns :: Seq (Seq Cell) -> Box Horizontal
- rowToBoxH :: Box Vertical -> Box Horizontal
- cellToBoxH :: Cell -> (Box Horizontal, Alignment Vertical, Radiant)
- addHeightMap :: Seq (Seq (Box Horizontal, b, c)) -> (Map Int (Int, Int), Seq (Seq (Box Horizontal, b, c)))
- tallestCellMap :: Seq (Seq (Box Horizontal)) -> Map Int (Int, Int)
- padBoxH :: Map Int (Int, Int) -> Seq (Seq (Box Horizontal, a, b)) -> Seq (Seq (Box Horizontal, a, b))
- toBoxV :: (Box Horizontal, Alignment Vertical, Radiant) -> Box Vertical
- equalize :: a -> Seq (Seq a) -> Seq (Seq a)
- mconcatSeq :: Monoid a => Seq a -> a
- intersperse :: a -> Seq a -> Seq a
- split :: Int -> (Int, Int)
Documentation
Alignment. Used in conjunction with Horizontal
and Vertical
,
this determines how a payload aligns with the axis of a Box
.
data Horizontal Source
Determines how a payload aligns with a horizontal axis.
Determines how a payload aligns with a vertical axis.
Place this payload so that it is centered on the vertical axis or horizontal axis.
centerH :: Alignment Horizontal Source
Center horizontally; like center
, but monomorphic.
top :: Alignment Horizontal Source
Place this payload's top edge on the horizontal axis.
bottom :: Alignment Horizontal Source
Place this payload's bottom edge on the horizontal axis.
An intermediate type used in rendering; it consists either of
text Chunk
or of a number of spaces coupled with a background color.
A list of screen rows; each screen row is a Seq
of Rod
.
A RodRows
with width but no height does nothing if rendered
alone, but it can affect the width of other RodRows
if combined
with them.
RodRowsWithHeight (Seq (Seq Rod)) | Each outer The outer |
RodRowsNoHeight Int | A |
A Payload
holds a RodRows
, which determines the number
and content of the screen rows. The Payload
also has an
Alignment
, which specifies how the payload aligns with the axis.
Whether the Alignment
is Horizontal
or Vertical
determines
the orientation of the Payload
. The Payload
also contains a
background color, which is type Radiant
. The background color
extends continuously from the Payload
in both directions that are
perpendicular to the axis.
addVerticalPadding :: Box Horizontal -> Seq RodRows Source
Adds padding to the top and bottom of each Payload. A Payload with a Core is converted to a RodRows and has padding added; a Payload with a RodRows has necessary padding added to the top and bottom. The number of elements in the resulting Seq is the same as the number of elements in the input Seq; no merging is performed.
horizontalMerge :: Seq RodRows -> RodRows Source
Merges multiple horizontal RodRows into a single RodRows. All RodRows must already have been the same height; if they are not the same height, undefined behavior occurs.
addHorizontalPadding :: Box Vertical -> Seq RodRows Source
Adds padding to the left and right of each Payload. A Payload with a Core is converted to a RodRows and has padding added; a Payload with a RodRows has necessary padding added to the left and right. The number of elements in the resulting Seq is the same as the number of elements in the input Seq; no merging is performed.
verticalMerge :: Seq RodRows -> RodRows Source
Merge multiple vertical RodRows into a single RodRows. Each RodRows should already be the same width.
A Box
is the central building block. It consists of zero or
more payloads; each payload has the same orientation, which is either
Horizontal
or Vertical
. This orientation also determines
the orientation of the entire Box
.
A Box
is a Monoid
so you can combine them using the usual
monoid functions. For a Box
Vertical
, the leftmost values
added with mappend
are at the top of the Box
; for a Box
Horizontal
, the leftmost values added with mappend
are on the
left side of the Box
.
class Orientation a where Source
This typeclass is responsible for transforming a Box
into
Rainbow Chunk
so they can be printed to your screen. This
requires adding appropriate whitespace with the right colors, as
well as adding newlines in the right places.
rodRows :: Box a -> RodRows Source
spacer :: Radiant -> Int -> Box a Source
Builds a one-dimensional box of the given size; its single
dimension is parallel to the axis. When added to a
box, it will insert blank space of the given length. For a Box
Horizontal
, this produces a horizontal line; for a Box
Vertical
, a vertical line.
spreader :: Alignment a -> Int -> Box a Source
Builds a one-dimensional box of the given size; its single
dimension is perpendicular to the axis. This can be used to make
a Box
Vertical
wider or a Box
Horizontal
taller.
class LeftRight a where Source
Things that are oriented around a vertical axis.
Length to the left of the vertical axis.
Length to the right of the vertical axis.
Things that are oriented around a horizontal axis.
Number of lines above the horizontal axis.
Number of lines below the horizontal axis.
:: Alignment a | |
-> Radiant | Background color. The background color in the |
-> Chunk | |
-> Box a |
Construct a box from a single Chunk
.
:: Orientation a | |
=> Alignment b | Alignment for new |
-> Radiant | Background color for new box |
-> Box a | |
-> Box b |
A single cell in a spreadsheet-like grid.
Cell | |
|
separator :: Radiant -> Int -> Cell Source
Creates a blank Cell
with the given background color and width;
useful for adding separators between columns.
tableByRows :: Seq (Seq Cell) -> Box Vertical Source
Create a table where each inner Seq
is a row of cells,
from left to right. If necessary, blank cells are added to the end
of a row to ensure that each row has the same number of cells as
the longest row.
cellToBoxV :: Cell -> (Box Vertical, Alignment Horizontal, Radiant) Source
toBoxH :: (Box Vertical, Alignment Horizontal, Radiant) -> Box Horizontal Source
addWidthMap :: Seq (Seq (Box Vertical, b, c)) -> (Map Int (Int, Int), Seq (Seq (Box Vertical, b, c))) Source
padBoxV :: Map Int (Int, Int) -> Seq (Seq (Box Vertical, a, b)) -> Seq (Seq (Box Vertical, a, b)) Source
tableByColumns :: Seq (Seq Cell) -> Box Horizontal Source
Create a table where each inner Seq
is a column of cells,
from top to bottom. If necessary, blank cells are added to the end
of a column to ensure that each column has the same number of cells
as the longest column.
cellToBoxH :: Cell -> (Box Horizontal, Alignment Vertical, Radiant) Source
addHeightMap :: Seq (Seq (Box Horizontal, b, c)) -> (Map Int (Int, Int), Seq (Seq (Box Horizontal, b, c))) Source
tallestCellMap :: Seq (Seq (Box Horizontal)) -> Map Int (Int, Int) Source
padBoxH :: Map Int (Int, Int) -> Seq (Seq (Box Horizontal, a, b)) -> Seq (Seq (Box Horizontal, a, b)) Source
equalize :: a -> Seq (Seq a) -> Seq (Seq a) Source
Ensures that each inner Seq
is the same length by adding the
given empty element where needed.
mconcatSeq :: Monoid a => Seq a -> a Source
intersperse :: a -> Seq a -> Seq a Source
Like intersperse
in Data.List, but works on Seq
.