-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | customizable pretty printer library for tables -- -- customizable pretty printer library for tables, e.g. using boxing -- characters @package hable @version 0.3.0 module Hable.BoxChar -- | Describes a styled box character. You can use any data type to -- represent a style as long as the charset of your -- Config supports it. -- -- Be careful with all these getter functions like bcVStyle as -- they are not complete. (E.g. bcHStyle (Bar ()) -- will fail with an exception error.) data BoxChar style -- | Represents a box character in the shape of |. Bar :: style -> BoxChar style [bcVStyle] :: BoxChar style -> style -- | Represents a box character in the shape of . Dash :: style -> BoxChar style [bcHStyle] :: BoxChar style -> style -- | Represents any other box character. -- -- Imagine a 2x2 table. The bcVPos and bcHPos use the -- Align data type to describe the position of the angled box -- character this Angled constructor represents. -- -- E.g. Angled HLeft foo VBottom bar -- represents an L-like shaped box character as that's the shape -- of the character at the bottom-left edge of a 2x2 table. -- -- Another example: Angled HCenter HCenter -- describes a box character shaped like a plus +. Angled :: HAxis -> style -> VAxis -> style -> BoxChar style [bcHPos] :: BoxChar style -> HAxis [bcHStyle] :: BoxChar style -> style [bcVPos] :: BoxChar style -> VAxis [bcVStyle] :: BoxChar style -> style -- | Describe a value (e.g. direction or position) on the horizontal axis. data HAxis -- | Means either on the left (in context of BoxChar) or -- to the left (in context of hAlign). HLeft :: HAxis -- | Means either inbetween left and right (in context of -- BoxChar) or (horizontally) centered (in context of -- hAlign). HCenter :: HAxis -- | Means either on the right (in context of BoxChar) or -- to the right (in context of hAlign). HRight :: HAxis -- | Describe a value (e.g. direction or position) on the vertical axis. data VAxis -- | Means at the top. VTop :: VAxis -- | Means either inbetween top and bottom (in context of -- BoxChar) or (vertically) centered (in context of -- vAlign). VCenter :: VAxis -- | Means at the bottom. VBottom :: VAxis instance GHC.Enum.Enum Hable.BoxChar.VAxis instance GHC.Enum.Enum Hable.BoxChar.HAxis -- | This module might be useful to understand the Hable's indexing of -- vertical and horizontal lines and maybe also to debug them. -- -- It offers a style, called LineIndexStyle which is a simple type -- synonym for Integer. This style is used to print the last digit -- of vertical line index (see vLineIndexcharset) or horizontal -- line index (see hLineIndexCharset). module Hable.Style.LineIndex type LineIndexStyle = Integer -- | Usage example: -- --
--   >>> putStr (hable defaultConfig { charset = vLineIndexCharset, vLineStyle = const Just, hLineStyle = const Just } [["foo","bar"],["baz","qux"]])
--   1-----2-----3
--   1 foo 2 bar 3
--   1-----2-----3
--   1 baz 2 qux 3
--   1-----2-----3
--   
vLineIndexCharset :: BoxChar LineIndexStyle -> String -- | Usage example: -- --
--   >>> putStr (hable defaultConfig { charset = hLineIndexCharset, vLineStyle = const Just, hLineStyle = const Just } [["foo","bar"],["baz","qux"]])
--   1111111111111
--   | foo | bar |
--   2222222222222
--   | baz | qux |
--   3333333333333
--   
hLineIndexCharset :: BoxChar LineIndexStyle -> String module Hable.Style.OrgMode -- | A charset based on the syntax of Emacs' Org-Mode -- spreadsheet. It uses +, - and | and ignores -- any style. -- -- An example output: -- --
--   >>> putStr (hable myConfig { charset = orgModeCharset, hStyleAt = \_ _ -> Just (), vStyleAt = \_ _ -> Just () } myTable)
--   |----------------------+------------------------------------------------|
--   | Name                 | Hable                                          |
--   |----------------------+------------------------------------------------|
--   | Synopsis             | customizable pretty printer library for tables |
--   |----------------------+------------------------------------------------|
--   | License              | Public Domain / Unlicense                      |
--   |----------------------+------------------------------------------------|
--   
orgModeCharset :: BoxChar style -> String type OrgModeStyle = () module Hable.Style.Unicode -- | This module uses a style data type supporting normal, double and thick -- lines. data UnicodeStyle Normal :: UnicodeStyle Double :: UnicodeStyle Thick :: UnicodeStyle -- | charset. Unfortunately, there is not a Unicode box character -- for all possible values of BoxChar Unicode. -- In case of such an input, an error is thrown. -- -- If you'd prefer an alternative behavior in that case, use -- maybeUnicodeCharset. -- -- An example output: -- --
--   >>> putStr (hable myConfig myTable)
--   ╒══════════════════════╤════════════════════════════════════════════════╕
--   │ Name                 │ Hable                                          │
--   ╞══════════════════════╪════════════════════════════════════════════════╡
--   │ Synopsis             │ customizable pretty printer library for tables │
--   │ License              │ Public Domain / Unlicense                      │
--   └──────────────────────┴────────────────────────────────────────────────┘
--   
unicodeCharset :: BoxChar UnicodeStyle -> String -- | Maybe returns a character representing the given BoxChar with -- Unicode box characters. maybeUnicodeCharset :: BoxChar UnicodeStyle -> Maybe String instance GHC.Show.Show Hable.Style.Unicode.UnicodeStyle -- | This module offers the Config data type (constructor) to -- configure hable. -- -- For further configuration, you might also want to take a look at the -- various pre-defined styles of Hable. The default configuration uses -- Unicode, so you might want to take a look at OrgMode and -- Colored8, too. module Hable.Config -- | Hable Configuration. data Config style Config :: (Integer -> Integer -> Maybe style) -> (Integer -> Integer -> Maybe style) -> (Integer -> HAxis) -> (Integer -> VAxis) -> Integer -> (BoxChar style -> String) -> Config style -- |

Horizontal line style.

-- -- The first argument is the index of the last possible horizontal line -- (i.e. number of rows + 1). -- -- The second argument receives the index of any horizontal line. -- -- If Nothing is returned, the horizontal line will be collapsed / -- hidden here. If Just a style is returned, this style will be -- used for the horizontal parts of the box character (BoxChar). [hLineStyle] :: Config style -> Integer -> Integer -> Maybe style -- |

Vertical line style.

-- -- The first argument is the index of the last possible vertical line -- (i.e. number of rows + 1). -- -- The second argument receives the index of any vertical line. -- -- If Nothing is returned, the vertical line will be collapsed / -- hidden here. If Just a style is returned, this style will be -- used for the vertical parts of the box character (BoxChar). [vLineStyle] :: Config style -> Integer -> Integer -> Maybe style -- |

Horizontal Alignment.

-- -- The argument is the index of any row. -- -- If HLeft is returned, the content of the cells in this row will -- be aligned to the left. If HCenter is returned, the content of -- the cells in this row will be centered. If HRight is returned, -- the content of the cells in this row will be aligned to the right. [hAlign] :: Config style -> Integer -> HAxis -- |

Vertical Alignment in case of multi-line cells.

-- -- The argument is the index of any column. -- -- If VTop is returned, the content of the cells in this column -- will be aligned to the top. If VCenter is returned, the content -- of the cells in this column will be centered. If VBottom is -- returned, the content of the cells in this column will be aligned to -- the bottom. [vAlign] :: Config style -> Integer -> VAxis -- |

Horizontal padding.

-- -- The number of spaces to be inserted between the cell content and the -- vertical lines on both the left and the right side of a cell. [hPadding] :: Config style -> Integer -- |

Charset.

-- -- The argument is a styled box character BoxChar. The style of it -- was calculated by hable using the hLineStyle and -- vLineStyle properties of your configuration. -- -- Returns a character (as string) to be used for the lines. [charset] :: Config style -> BoxChar style -> String -- | The default configuration uses Unicode box characters. defaultConfig :: Config UnicodeStyle -- | This module allows you to add colors to another style for Hable -- configuration. -- -- To add a single color to the whole table, it's the most simple to use -- colored8Config. -- -- If you'd like to color vertical lines independently from horizontal -- lines, use colored8Charset and don't forget to compose -- Colored8 to the hLineStyle and vLineStyle -- properties of your config appropriately. -- -- If you'd like to decide yourself how to act at the points of the table -- where vertical and horizontal lines are cutting across, use -- genColored8charset. module Hable.Style.Colored8 -- | Represents the eight colors supported by most terminal emulators -- through ANSI escape codes. data Color8 Black :: Color8 Red :: Color8 Green :: Color8 Yellow :: Color8 Blue :: Color8 Magenta :: Color8 Cyan :: Color8 White :: Color8 -- | A wrapper for any other style, adding an option of a fore- as well as -- a background color to it. For the color fields, Nothing -- represents an unchanged/unmodified/unset color. data Colored8 style Colored8 :: Maybe Color8 -> Maybe Color8 -> style -> Colored8 style [foreground] :: Colored8 style -> Maybe Color8 [background] :: Colored8 style -> Maybe Color8 [colored8Style] :: Colored8 style -> style -- | Add colors to a configuration. -- -- The first argument may be a foreground color. If it's Nothing, -- the foreground won't be modified. -- -- The second argument may be a background color. If it's Nothing, -- the background won't be modified. -- -- The third argument is the configuration to be colored. colored8Config :: Maybe Color8 -> Maybe Color8 -> Config style -> Config (Colored8 style) -- | Given a charset, returns another new one which supports colors -- through a Colored8 style. -- -- An example which circles the colors of the horizontal lines using -- mod -- --
--   >>> putStr (hable defaultConfig { charset = colored8Charset (charset defaultConfig), vLineStyle = _ _ -> Nothing, hLineStyle = m n -> fmap (Colored8 (Just (toEnum (fromInteger ((n mod 6) + 1)))) Nothing) $ vLineStyle defaultConfig m n } exampleTable)
--   
-- -- Unfortunately, you wouldn't see the colors here, so there's a picture: -- colored8Charset :: (BoxChar style -> String) -> BoxChar (Colored8 style) -> String -- | A generalization of colored8Charset. Instead of simply using -- choosing the vertical color components for Angled box -- characters, you can pass your own function to decide which color to -- choose in this case. E.g. you could write a function which uses a -- completely different color. -- -- All in all, the first argument of genColored8charset is a -- function. Its arguments are the same as the arguments of the -- Angled constructor. genColored8Charset :: (HAxis -> Colored8 style -> VAxis -> Colored8 style -> (Maybe Color8, Maybe Color8)) -> (BoxChar style -> String) -> BoxChar (Colored8 style) -> String -- | Wraps a String into the ANSI escape codes of the given fore- -- and background colors. color8String :: Maybe Color8 -> Maybe Color8 -> String -> String instance GHC.Enum.Enum Hable.Style.Colored8.Color8 instance GHC.Classes.Eq Hable.Style.Colored8.Color8 -- | Pretty-print a table in a configurable way. -- -- Using the default configuration, this program: -- --
--   import Hable
--   
--   main :: IO ()
--   main = putStr (hable defaultConfig exampleTable)
--   
--   exampleTable =
--       [ [ "one", "two", "three", Hable ]
--       , [ "hellonworld", "loremnipsumndolornsit amet", "verryyyyyy llooong", "is"]
--       , [ "super", "awesome", "freaking", "amazing" ]
--       ]
--   
-- -- will result in: -- --
--   ╔═══════╤══════════╤════════════════════╤═════════╗
--   ║ one   │ two      │ three              │ Hable   ║
--   ╟───────┼──────────┼────────────────────┼─────────╢
--   ║ hello │ lorem    │ verryyyyyy llooong │ is      ║
--   ║ world │ ipsum    │                    │         ║
--   ║       │ dolor    │                    │         ║
--   ║       │ sit amet │                    │         ║
--   ╟───────┼──────────┼────────────────────┼─────────╢
--   ║ super │ awesome  │ freaking           │ amazing ║
--   ╚═══════╧══════════╧════════════════════╧═════════╝
--   
-- -- See Config for configuration. module Hable -- | Pretty-prints a row-wise given table using a given Hable -- Configuration. hable :: Config style -> [[String]] -> String -- | The default configuration uses Unicode box characters. defaultConfig :: Config UnicodeStyle