tkemps / unicode-table

Haskell library that prints text tables with unicode symbols for borders and edges

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This package allows you to print simple text tables with suitable unicode characters for borders and edges.

Example:

{-# LANGUAGE OverloadedStrings, FlexibleContexts #-}
module Main where

import Data.Array.IArray
import Data.Text.Lazy.Builder
import Text.UnicodeTable

main = do
    let content = array ((0,0),(5,5)) [((r,c), fromString . show $ (r,c)) | r <- [0..5], c <- [0..5]]
    let ws = listArray (0,5) (replicate 6 20)
    let hs = listArray (0,6) (replicate 7 SingleLine) // [(1, DoubleLine)]
    let vs = listArray (0,6) (replicate 7 SingleLine)
    let tbl = mkTable content ws hs vs
    print tbl

This gives the following output:

┌────────────────────┬────────────────────┬────────────────────┬────────────────────┬────────────────────┬────────────────────┐
│               (0,0)│               (0,1)│               (0,2)│               (0,3)│               (0,4)│               (0,5)│
╞════════════════════╪════════════════════╪════════════════════╪════════════════════╪════════════════════╪════════════════════╡
│               (1,0)│               (1,1)│               (1,2)│               (1,3)│               (1,4)│               (1,5)│
├────────────────────┼────────────────────┼────────────────────┼────────────────────┼────────────────────┼────────────────────┤
│               (2,0)│               (2,1)│               (2,2)│               (2,3)│               (2,4)│               (2,5)│
├────────────────────┼────────────────────┼────────────────────┼────────────────────┼────────────────────┼────────────────────┤
│               (3,0)│               (3,1)│               (3,2)│               (3,3)│               (3,4)│               (3,5)│
├────────────────────┼────────────────────┼────────────────────┼────────────────────┼────────────────────┼────────────────────┤
│               (4,0)│               (4,1)│               (4,2)│               (4,3)│               (4,4)│               (4,5)│
├────────────────────┼────────────────────┼────────────────────┼────────────────────┼────────────────────┼────────────────────┤
│               (5,0)│               (5,1)│               (5,2)│               (5,3)│               (5,4)│               (5,5)│
└────────────────────┴────────────────────┴────────────────────┴────────────────────┴────────────────────┴────────────────────┘

About

Haskell library that prints text tables with unicode symbols for borders and edges

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Haskell 100.0%