pptable: Pretty Print containers in a tabular format

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Please see README.md


[Skip to Readme]

Properties

Versions 0.1.0.0, 0.1.0.1, 0.2.0.0, 0.2.0.0, 0.3.0.0
Change log CHANGELOG.md
Dependencies base (>=4.7 && <5), boxes, containers, generic-deriving, pretty, syb, vector [details]
License MIT
Copyright 2016 Guru Devanla
Author Guru Devanla
Maintainer grdvnl@gmail.com
Category Text
Home page https://github.com/gdevanla/pptable#readme
Source repo head: git clone https://github.com/gdevanla/pptable
Uploaded by gdevanla at 2016-10-05T05:04:06Z

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for pptable-0.2.0.0

[back to package description]

README

Text.PrettyPrint.Tabulate : Print any list, vector or map as a well-formatted readable table.

Text.PrettyPrint.Tabulate

Example


  -- ./Example.hs
  :set -XDeriveGeneric
  :set -XDeriveDataTypeable

  import qualified GHC.Generics as G
  import Data.Data

  import qualified Text.PrettyPrint.Tabulate as T
  import qualified Data.Map as Map
  import qualified Data.List as List
  import qualified Data.Vector as Vector


  data Stock = Stock {ticker::String, price::Double, marketCap::Double} deriving (Data, G.Generic)
  instance T.Tabulate Stock

  let yahoo =  Stock {ticker="YHOO", price=42.29101010, marketCap=40e9}
  let google = Stock {ticker="GOOG", price=774.210101, marketCap=532.09e9}
  let amazon = Stock {ticker="AMZN", price=799.161717, marketCap=378.86e9}


  -- List of records
  let tickers = [yahoo, google, amazon]

  -- The record type 'Stock' can also be in a Map
  let tickers_map = Map.fromList [(10, yahoo), (100, google), (1000, amazon)]

  -- Or in a Vector
  let tickers_vector = Vector.fromList tickers

  -- Print table from List
  T.ppTable tickers
   ticker     price              marketCap
   YHOO         42.291010100     4.000000000e10
   GOOG        774.210101000     5.320900000e11
   AMZN        799.161717000     3.788600000e11

   -- Print table from Map
   T.ppTable tickers_map
   Key      ticker     price              marketCap
   10       YHOO         42.291010100     4.000000000e10
   100      GOOG        774.210101000     5.320900000e11
   1000     AMZN        799.161717000     3.788600000e11


   -- Print table from Vector
   T.ppTable tickers_vector
   ticker     price              marketCap
   YHOO         42.291010100     4.000000000e10
   GOOG        774.210101000     5.320900000e11
   AMZN        799.161717000     3.788600000e11