-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Pretty Print containers in a tabular format -- -- When you are faced with tens of records data types contained in a list -- or similar structure if becomes difficult to view all records during -- iterative development. This library provides a generic funciton to -- print any such record types in a tabular format that makes visualizing -- the data more pleasing. Please see README.md for examples of this. @package pptable @version 0.3.0.0 -- | Module implements the default methods for Tabulate All examples listed -- in the document need the following language pragmas and following -- modules imported -- --
-- {#- LANGUAGE MultiParamTypeClasses}
-- {#- LANGUAGE DeriveGeneric}
-- {#- LANGUAGE DeriveDataTypeable}
--
-- import qualified GHC.Generics as G
-- import Data.Data
--
module Text.PrettyPrint.Tabulate
-- | Class instance that needs to be instantiated for each record that
-- needs to be printed using printTable
--
--
-- data Stock = Stock {price:: Double, name:: String} derive (Show, G.Generic, Data)
-- instance Tabulate S ExpandWhenNested
--
--
-- If S is embedded inside another Record type and should
-- be displayed in regular Record Syntax, then
--
-- -- instance Tabulate S DoNotExpandWhenNested --class Tabulate a flag | a -> flag class Boxable b -- | Used to print a container of Records in a tabular format. -- --
-- data Stock = Stock {price:: Double, ticker:: String} deriving (Show, Data, G.Generic)
-- instance Tabulate Stock DoNotExpandWhenNested
-- -- this can be a Vector or Map
-- let s = [Stock 10.0 "yahoo", Stock 12.0 "goog", Stock 10.0 "amz"]
-- T.printTable s
--
--
-- Nested records can also be printed in tabular format
--
--
-- data FxCode = USD | EUR deriving (Show, Data, G.Generic)
-- instance CellValueFormatter FxCode
--
-- data Price = Price {px:: Double, fxCode:: FxCode} deriving (Show, Data, G.Generic)
-- instance Tabulate Price ExpandWhenNested
-- -- since Price will be nested, it also needs an instance of
-- -- CellValueFormatter
-- instance CellValueFormatter Price
--
-- data Stock = Stock {ticker:: String, price:: Price} deriving (Show, Data, G.Generic)
-- instance Tabulate Stock DoNotExpandWhenNested
--
-- -- this can be a Vector or Map
-- let s = [Stock "yahoo" (Price 10.0 USD), Stock "ikea" (Price 11.0 EUR)]
-- printTable s
--
printTable :: (Boxable b, Generic a, GRecordMeta (Rep a)) => b a -> IO ()
-- | Similar to printTable but rather than return IO (), returns a
-- Box object that can be printed later on, using
-- printBox
renderTable :: (Boxable b, Generic a, GRecordMeta (Rep a)) => b a -> Box
-- | Used for printing selected fields from Record types This is useful
-- when Records have a large number of fields and only few fields need to
-- be introspected at any time.
--
-- Using the example provided under printTables,
--
-- -- printTableWithFlds [DFld (px . price), DFld ticker] s --printTableWithFlds :: Boxable b => [DisplayFld t] -> b t -> IO () -- | Same as printTableWithFlds but returns a Box object, rather -- than returning an `IO ()`. renderTableWithFlds :: Boxable b => [DisplayFld t] -> b t -> Box -- | Class that implements formatting using printf. Default instances for -- String, Char, Int, Integer, Double and Float are provided. For types -- that are not an instance of this class show is used. class CellValueFormatter a -- | Use this flag to expand a Record Type as a table when nested inside -- another record. data ExpandWhenNested -- | Use this flag to not expand a Record type as a table when nested -- inside another record. The Show instance of the nested record -- is used by default without expanding. This means that the fields of -- the nested record are not displayed as separate headers. data DoNotExpandWhenNested -- | Used with printTableWithFlds data DisplayFld a DFld :: (a -> s) -> DisplayFld a instance GHC.Show.Show Text.PrettyPrint.Tabulate.R3 instance GHC.Generics.Generic Text.PrettyPrint.Tabulate.R3 instance GHC.Show.Show Text.PrettyPrint.Tabulate.R2 instance GHC.Generics.Generic Text.PrettyPrint.Tabulate.R2 instance GHC.Generics.Generic Text.PrettyPrint.Tabulate.T1 instance GHC.Show.Show Text.PrettyPrint.Tabulate.T1 instance Data.Data.Data Text.PrettyPrint.Tabulate.T1 instance GHC.Generics.Generic Text.PrettyPrint.Tabulate.T instance GHC.Show.Show Text.PrettyPrint.Tabulate.T instance Data.Data.Data Text.PrettyPrint.Tabulate.T instance GHC.Show.Show Text.PrettyPrint.Tabulate.Tag instance Text.PrettyPrint.Tabulate.Boxable [] instance Text.PrettyPrint.Tabulate.Boxable Data.Vector.Vector instance Text.PrettyPrint.Tabulate.CellValueFormatter k => Text.PrettyPrint.Tabulate.Boxable (Data.Map.Internal.Map k) instance Text.PrettyPrint.Tabulate.Tabulate Text.PrettyPrint.Tabulate.T1 Text.PrettyPrint.Tabulate.ExpandWhenNested instance Text.PrettyPrint.Tabulate.Tabulate Text.PrettyPrint.Tabulate.T Text.PrettyPrint.Tabulate.ExpandWhenNested instance Text.PrettyPrint.Tabulate.CellValueFormatter Text.PrettyPrint.Tabulate.T instance (Text.PrettyPrint.Tabulate.CellValueFormatter a, Data.Data.Data a, Text.PrettyPrint.Tabulate.RecordMeta a) => Text.PrettyPrint.Tabulate.GRecordMeta (GHC.Generics.K1 i a) instance Text.PrettyPrint.Tabulate.CellValueFormatter a => Text.PrettyPrint.Tabulate.RecordMeta' Text.PrettyPrint.Tabulate.DoNotExpandWhenNested a instance Text.PrettyPrint.Tabulate.CellValueFormatter GHC.Integer.Type.Integer instance Text.PrettyPrint.Tabulate.CellValueFormatter GHC.Types.Int instance Text.PrettyPrint.Tabulate.CellValueFormatter GHC.Types.Float instance Text.PrettyPrint.Tabulate.CellValueFormatter GHC.Base.String instance Text.PrettyPrint.Tabulate.CellValueFormatter GHC.Types.Double instance Text.PrettyPrint.Tabulate.CellValueFormatter GHC.Types.Bool instance (GHC.Show.Show a, Text.PrettyPrint.Tabulate.CellValueFormatter a) => Text.PrettyPrint.Tabulate.CellValueFormatter (GHC.Base.Maybe a) instance (Text.PrettyPrint.Tabulate.Tabulate a flag, Text.PrettyPrint.Tabulate.RecordMeta' flag a) => Text.PrettyPrint.Tabulate.RecordMeta a instance (GHC.Generics.Generic a, Text.PrettyPrint.Tabulate.GRecordMeta (GHC.Generics.Rep a)) => Text.PrettyPrint.Tabulate.RecordMeta' Text.PrettyPrint.Tabulate.ExpandWhenNested a instance flag ~ Text.PrettyPrint.Tabulate.DoNotExpandWhenNested => Text.PrettyPrint.Tabulate.Tabulate a flag instance Text.PrettyPrint.Tabulate.GRecordMeta GHC.Generics.U1 instance (Text.PrettyPrint.Tabulate.GRecordMeta a, Text.PrettyPrint.Tabulate.GRecordMeta b) => Text.PrettyPrint.Tabulate.GRecordMeta (a GHC.Generics.:*: b) instance (Text.PrettyPrint.Tabulate.GRecordMeta a, Text.PrettyPrint.Tabulate.GRecordMeta b) => Text.PrettyPrint.Tabulate.GRecordMeta (a GHC.Generics.:+: b) instance (Text.PrettyPrint.Tabulate.GRecordMeta a, GHC.Generics.Selector s) => Text.PrettyPrint.Tabulate.GRecordMeta (GHC.Generics.M1 GHC.Generics.S s a) instance (Text.PrettyPrint.Tabulate.GRecordMeta a, GHC.Generics.Constructor c) => Text.PrettyPrint.Tabulate.GRecordMeta (GHC.Generics.M1 GHC.Generics.C c a) instance Text.PrettyPrint.Tabulate.GRecordMeta a => Text.PrettyPrint.Tabulate.GRecordMeta (GHC.Generics.M1 GHC.Generics.D c a)