Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Clerk
library
Synopsis
- data Coords = Coords {}
- newtype CellRef a = CellRef {}
- getCol :: CellRef a -> Int
- getRow :: CellRef a -> Int
- overCol :: (Int -> Int) -> Coords -> Coords
- overRow :: (Int -> Int) -> Coords -> Coords
- unsafeChangeCellRefType :: forall b a. CellRef a -> CellRef b
- type InputIndex = Int
- type FormatCell = Coords -> InputIndex -> CellData -> FormattedCell
- data CellTemplate input output
- type FormattedMap = Map (RowIndex, ColumnIndex) FormattedCell
- type FMTransform = FormattedMap -> FormattedMap
- type WSTransform = Worksheet -> Worksheet
- data Transform
- type FCTransform = FormattedCell -> FormattedCell
- horizontalAlignment :: CellHorizontalAlignment -> FCTransform
- mkColorStyle :: Show a => a -> FormatCell
- newtype RowBuilder input output a = RowBuilder {}
- newtype Template input output = Template [CellTemplate input output]
- newtype ColumnsProperties = ColumnsProperties {}
- columnWidthCell :: forall a input output. Maybe Double -> FormatCell -> (input -> output) -> RowBuilder input output (CellRef a)
- columnWidth :: ToCellData output => Double -> FormatCell -> (input -> output) -> RowBuilder input CellData (CellRef a)
- columnWidth_ :: ToCellData output => Double -> FormatCell -> (input -> output) -> RowBuilder input CellData ()
- column :: ToCellData output => FormatCell -> (input -> output) -> RowBuilder input CellData (CellRef a)
- column_ :: ToCellData output => FormatCell -> (input -> output) -> RowBuilder input CellData ()
- newtype SheetBuilder a = SheetBuilder {}
- placeInputs :: ToCellData output => Coords -> [input] -> RowBuilder input output a -> SheetBuilder a
- placeInputs_ :: ToCellData output => Coords -> [input] -> RowBuilder input output a -> SheetBuilder ()
- placeInput :: ToCellData output => Coords -> input -> RowBuilder input output a -> SheetBuilder a
- placeInput_ :: ToCellData output => Coords -> input -> RowBuilder input output a -> SheetBuilder ()
- data Expr t
- class ToExpr v where
- type ArithmeticOperator a b c = (Num a, ToExpr (b a), ToExpr (c a)) => b a -> c a -> Expr a
- (|+|) :: ArithmeticOperator a b c
- (|-|) :: ArithmeticOperator a b c
- (|*|) :: ArithmeticOperator a b c
- (|/|) :: ArithmeticOperator a b c
- (|:|) :: CellRef a -> CellRef b -> Expr c
- (|^|) :: ArithmeticOperator a b c
- (|$|) :: ToExpr a => String -> [a] -> Expr t
- (+>) :: FormatCell -> FCTransform -> FormatCell
- data CellData
- class ToCellData a where
- toCellData :: a -> CellData
- composeXlsx :: [(Text, SheetBuilder ())] -> Xlsx
Coords
Coords of a cell
Cell references
{- FOURMOLU_ENABLE -}
A typed reference to a cell.
The user is responsible for setting the necessary cell type.
The type prevents operations between cell references with incompatible types.
>>>
str = CellRef (Coords 1 1) :: CellRef String
>>>
str |+| str
No instance for (Num String) arising from a use of ‘|+|’
When necessary, the user may change the cell reference type via unsafeChangeCellRefType
>>>
int = CellRef (Coords 1 1) :: CellRef Int
>>>
double = CellRef (Coords 2 5) :: CellRef Double
>>>
unsafeChangeCellRefType int |+| double
A1+E2
unsafeChangeCellRefType :: forall b a. CellRef a -> CellRef b Source #
Change the type of a cell reference. Use with caution!
The type variables in the forall
clause are swapped for the conveniece of type applications
Cell formatting
type InputIndex = Int Source #
Index of an input
type FormatCell = Coords -> InputIndex -> CellData -> FormattedCell Source #
Format a single cell depending on its coordinates, index, and data
data CellTemplate input output Source #
Template of a cell with contents, style, column properties
type FormattedMap = Map (RowIndex, ColumnIndex) FormattedCell Source #
Map of coordinates to cell formatting
type FMTransform = FormattedMap -> FormattedMap Source #
Transform of a map that maps coordinates to cell formatting
type WSTransform = Worksheet -> Worksheet Source #
Transform of a worksheet
Combined: a transform of a map of formats and a transform of a worksheet
Instances
Monoid Transform Source # | |
Semigroup Transform Source # | |
Default Transform Source # | |
MonadWriter Transform SheetBuilder Source # | |
Defined in Clerk writer :: (a, Transform) -> SheetBuilder a # tell :: Transform -> SheetBuilder () # listen :: SheetBuilder a -> SheetBuilder (a, Transform) # pass :: SheetBuilder (a, Transform -> Transform) -> SheetBuilder a # |
type FCTransform = FormattedCell -> FormattedCell Source #
Transform of a formatted cell
horizontalAlignment :: CellHorizontalAlignment -> FCTransform Source #
Get a FCTransform
with a given horizontal alignment in a cell
mkColorStyle :: Show a => a -> FormatCell Source #
Make a FormatCell
for a single color
show
on the input should translate into an ARGB
color. See Color
Templates
newtype RowBuilder input output a Source #
Allows to describe how to build a template for a row
Instances
MonadState Coords (RowBuilder input output) Source # | |
Defined in Clerk get :: RowBuilder input output Coords # put :: Coords -> RowBuilder input output () # state :: (Coords -> (a, Coords)) -> RowBuilder input output a # | |
Applicative (RowBuilder input output) Source # | |
Defined in Clerk pure :: a -> RowBuilder input output a # (<*>) :: RowBuilder input output (a -> b) -> RowBuilder input output a -> RowBuilder input output b # liftA2 :: (a -> b -> c) -> RowBuilder input output a -> RowBuilder input output b -> RowBuilder input output c # (*>) :: RowBuilder input output a -> RowBuilder input output b -> RowBuilder input output b # (<*) :: RowBuilder input output a -> RowBuilder input output b -> RowBuilder input output a # | |
Functor (RowBuilder input output) Source # | |
Defined in Clerk fmap :: (a -> b) -> RowBuilder input output a -> RowBuilder input output b # (<$) :: a -> RowBuilder input output b -> RowBuilder input output a # | |
Monad (RowBuilder input output) Source # | |
Defined in Clerk (>>=) :: RowBuilder input output a -> (a -> RowBuilder input output b) -> RowBuilder input output b # (>>) :: RowBuilder input output a -> RowBuilder input output b -> RowBuilder input output b # return :: a -> RowBuilder input output a # | |
MonadWriter (Template input output) (RowBuilder input output) Source # | |
Defined in Clerk writer :: (a, Template input output) -> RowBuilder input output a # tell :: Template input output -> RowBuilder input output () # listen :: RowBuilder input output a -> RowBuilder input output (a, Template input output) # pass :: RowBuilder input output (a, Template input output -> Template input output) -> RowBuilder input output a # |
newtype Template input output Source #
Template for multiple cells
Template [CellTemplate input output] |
Instances
Monoid (Template input output) Source # | |
Semigroup (Template input output) Source # | |
MonadWriter (Template input output) (RowBuilder input output) Source # | |
Defined in Clerk writer :: (a, Template input output) -> RowBuilder input output a # tell :: Template input output -> RowBuilder input output () # listen :: RowBuilder input output a -> RowBuilder input output (a, Template input output) # pass :: RowBuilder input output (a, Template input output -> Template input output) -> RowBuilder input output a # |
Columns
newtype ColumnsProperties Source #
Properties of a column
Instances
Default ColumnsProperties Source # | |
Defined in Clerk |
columnWidthCell :: forall a input output. Maybe Double -> FormatCell -> (input -> output) -> RowBuilder input output (CellRef a) Source #
A column with a possibly given width and cell format. Returns a cell reference
columnWidth :: ToCellData output => Double -> FormatCell -> (input -> output) -> RowBuilder input CellData (CellRef a) Source #
A column with a given width and cell format. Returns a cell reference
columnWidth_ :: ToCellData output => Double -> FormatCell -> (input -> output) -> RowBuilder input CellData () Source #
A column with a given width and cell format
column :: ToCellData output => FormatCell -> (input -> output) -> RowBuilder input CellData (CellRef a) Source #
A column with a given cell format. Returns a cell reference
column_ :: ToCellData output => FormatCell -> (input -> output) -> RowBuilder input CellData () Source #
A column with a given cell format
Sheet builder
newtype SheetBuilder a Source #
A builder to compose the results of RowBuilder
s
Instances
Applicative SheetBuilder Source # | |
Defined in Clerk pure :: a -> SheetBuilder a # (<*>) :: SheetBuilder (a -> b) -> SheetBuilder a -> SheetBuilder b # liftA2 :: (a -> b -> c) -> SheetBuilder a -> SheetBuilder b -> SheetBuilder c # (*>) :: SheetBuilder a -> SheetBuilder b -> SheetBuilder b # (<*) :: SheetBuilder a -> SheetBuilder b -> SheetBuilder a # | |
Functor SheetBuilder Source # | |
Defined in Clerk fmap :: (a -> b) -> SheetBuilder a -> SheetBuilder b # (<$) :: a -> SheetBuilder b -> SheetBuilder a # | |
Monad SheetBuilder Source # | |
Defined in Clerk (>>=) :: SheetBuilder a -> (a -> SheetBuilder b) -> SheetBuilder b # (>>) :: SheetBuilder a -> SheetBuilder b -> SheetBuilder b # return :: a -> SheetBuilder a # | |
MonadWriter Transform SheetBuilder Source # | |
Defined in Clerk writer :: (a, Transform) -> SheetBuilder a # tell :: Transform -> SheetBuilder () # listen :: SheetBuilder a -> SheetBuilder (a, Transform) # pass :: SheetBuilder (a, Transform -> Transform) -> SheetBuilder a # |
placeInputs :: ToCellData output => Coords -> [input] -> RowBuilder input output a -> SheetBuilder a Source #
Starting at given coordinates, place rows of data made from a list of inputs according to a row builder. Return the result of the row builder.
placeInputs_ :: ToCellData output => Coords -> [input] -> RowBuilder input output a -> SheetBuilder () Source #
Starting at given coordinates, place rows of data made from a list of inputs according to a row builder.
placeInput :: ToCellData output => Coords -> input -> RowBuilder input output a -> SheetBuilder a Source #
Starting at given coordinates, place a row of data made from a single input according to a row builder. Return the result of the row builder.
placeInput_ :: ToCellData output => Coords -> input -> RowBuilder input output a -> SheetBuilder () Source #
Starting at given coordinates, place a row of data made from a single input according to a row builder.
Expressions
Expression syntax
Add (Expr t) (Expr t) | |
Sub (Expr t) (Expr t) | |
Mul (Expr t) (Expr t) | |
Div (Expr t) (Expr t) | |
Power (Expr t) (Expr t) | |
Function String [Expr t] | |
Range (Expr t) (Expr t) | |
ExprCell (CellRef t) |
Something that can be turned into an expression
type ArithmeticOperator a b c = (Num a, ToExpr (b a), ToExpr (c a)) => b a -> c a -> Expr a Source #
A type for arithmetic operators
(|+|) :: ArithmeticOperator a b c infixl 6 Source #
Assemble an addition expression
(|-|) :: ArithmeticOperator a b c infixl 6 Source #
Assemble a subtraction expression
(|*|) :: ArithmeticOperator a b c infixl 6 Source #
Assemble a multiplication expression
(|/|) :: ArithmeticOperator a b c infixl 7 Source #
Assemble a division expression
(|^|) :: ArithmeticOperator a b c infixr 8 Source #
Assemble a multiplication expression
(+>) :: FormatCell -> FCTransform -> FormatCell infixl 5 Source #
Apply FCTransform
to a FormatCell
to get a new FormatCell
Cells
A union of what can be inside a cell
Instances
class ToCellData a where Source #
Something that can be turned into CellData
toCellData :: a -> CellData Source #
Instances
Produce xlsx
composeXlsx :: [(Text, SheetBuilder ())] -> Xlsx Source #
Compose an xlsx
from a list of sheet names and builders