{-| 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 ( LineIndexStyle(..) , vLineIndexCharset , hLineIndexCharset ) where -------------------------------------------------------------------------------- import Hable.BoxChar -------------------------------------------------------------------------------- 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 vLineIndexCharset (Bar v) = [last (show v)] vLineIndexCharset (Dash h) = "-" vLineIndexCharset (Angled _ v _ _) = [last (show v)] -------------------------------------------------------------------------------- -- | 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 hLineIndexCharset (Bar v) = "|" hLineIndexCharset (Dash h) = [last (show h)] hLineIndexCharset (Angled _ _ _ h) = [last (show h)]