Safe Haskell | None |
---|---|
Language | Haskell2010 |
Module implements the default methods for Tabilize
- class Data a => Tabilize a where
- printList :: Tabilize a => [a] -> IO ()
- printMap :: (Tabilize a, Show b) => Map b a -> IO ()
- printVector :: Tabilize a => Vector a -> IO ()
- listToBox :: Tabilize a => [a] -> [[Box]]
- mapToBox :: (Tabilize a, Show b) => Map b a -> [[Box]]
- vectorToBox :: Tabilize a => Vector a -> [[Box]]
Documentation
class Data a => Tabilize a where Source #
Specialized class that provides default methods methods to print List, Map or Vector values as a pretty table
listToBox :: [a] -> [[Box]] Source #
Return a list of values wrapped in a Box. Each entry in input is assumed to be a list of records keyed by any data type. The first entry in the list of values will be used to infer the names of fields
mapToBox :: Show b => Map b a -> [[Box]] Source #
Return a list of values wrapped in Box. Each entry in input is assumed to be a list of records keyed by any data type. The first entry in the list of values will be used to infer the names of fields
vectorToBox :: Vector a -> [[Box]] Source #
Return a list of values wrapped in Box. Each entry in input is assumed to be a list of records keyed by any data type. The first entry in the list of values will be used to infer the names of fields
listToBox :: (Generic a, GTabilize (Rep a)) => [a] -> [[Box]] Source #
Return a list of values wrapped in a Box. Each entry in input is assumed to be a list of records keyed by any data type. The first entry in the list of values will be used to infer the names of fields
mapToBox :: (Generic a, GTabilize (Rep a), Show b) => Map b a -> [[Box]] Source #
Return a list of values wrapped in Box. Each entry in input is assumed to be a list of records keyed by any data type. The first entry in the list of values will be used to infer the names of fields
vectorToBox :: (Generic a, GTabilize (Rep a)) => Vector a -> [[Box]] Source #
Return a list of values wrapped in Box. Each entry in input is assumed to be a list of records keyed by any data type. The first entry in the list of values will be used to infer the names of fields
printMap :: Show b => Map b a -> IO () Source #
import qualified Data.Map as M -- declare a Map data Portfolio = M.Map String Stock Add the Stock values we create let p = M.fromList [("YHOO", yahoo), ("GOOG", google), ("AMZN" amazon)] printMap p Key ticker price marketCap "amzn" "AMZN" 799.161717 3.7886e11 "goog" "GOOG" 774.210101 5.3209e11 "yhoo" "YHOO" 42.2910101 4.0e10
printList :: [a] -> IO () Source #
-- List of records let tickers = [yahoo, google, amazon] printList tickers ticker price marketCap "YHOO" 42.2910101 4.0e10 "GOOG" 774.210101 5.3209e11 "AMZN" 799.161717 3.7886e11
printVector :: Vector a -> IO () Source #
import qualified Data.Vector as V -- Vector of records let tickers = V.fromList [yahoo, google, amazon] printVector tickers ticker price marketCap "YHOO" 42.2910101 4.0e10 "GOOG" 774.210101 5.3209e11 "AMZN" 799.161717 3.7886e11
printList :: Tabilize a => [a] -> IO () Source #
-- List of records let tickers = [yahoo, google, amazon] printList tickers ticker price marketCap "YHOO" 42.2910101 4.0e10 "GOOG" 774.210101 5.3209e11 "AMZN" 799.161717 3.7886e11
printMap :: (Tabilize a, Show b) => Map b a -> IO () Source #
import qualified Data.Map as M -- declare a Map data Portfolio = M.Map String Stock Add the Stock values we create let p = M.fromList [("YHOO", yahoo), ("GOOG", google), ("AMZN" amazon)] printMap p Key ticker price marketCap "amzn" "AMZN" 799.161717 3.7886e11 "goog" "GOOG" 774.210101 5.3209e11 "yhoo" "YHOO" 42.2910101 4.0e10
printVector :: Tabilize a => Vector a -> IO () Source #
import qualified Data.Vector as V -- Vector of records let tickers = V.fromList [yahoo, google, amazon] printVector tickers ticker price marketCap "YHOO" 42.2910101 4.0e10 "GOOG" 774.210101 5.3209e11 "AMZN" 799.161717 3.7886e11
listToBox :: Tabilize a => [a] -> [[Box]] Source #
Return a list of values wrapped in a Box. Each entry in input is assumed to be a list of records keyed by any data type. The first entry in the list of values will be used to infer the names of fields