haskell-awk-1.0: Transform text from the command-line using Haskell expressions.

Safe HaskellSafe-Inferred

System.Console.Hawk.Representable

Description

Used by Hawk's runtime to format the output of a Hawk expression. You can use this from your user prelude if you want Hawk to print your custom datatypes in a console-friendly format.

Synopsis

Documentation

class Show a => ListAsRow a where

A type that instantiate ListAsRow is a type that has a representation when is embedded inside a list

For example:

>>> mapM_ Data.ByteString.Lazy.Char8.putStrLn $ repr Data.ByteString.Lazy.Char8.empty "test"
test

Methods

listRepr' :: ByteString -> [a] -> ByteString

Instances

ListAsRow Bool 
ListAsRow Char 
ListAsRow Double 
ListAsRow Float 
ListAsRow Int 
ListAsRow Integer 
ListAsRow () 
ListAsRow ByteString 
ListAsRow a => ListAsRow [a] 
Row a => ListAsRow (Maybe a) 
ListAsRow a => ListAsRow (Set a) 
(Row a, Row b) => ListAsRow (a, b) 
(Row a, Row b) => ListAsRow (Map a b) 
(Row a, Row b, Row c) => ListAsRow (a, b, c) 
(Row a, Row b, Row c, Row d) => ListAsRow (a, b, c, d) 
(Row a, Row b, Row c, Row d, Row e) => ListAsRow (a, b, c, d, e) 
(Row a, Row b, Row c, Row d, Row e, Row f) => ListAsRow (a, b, c, d, e, f) 
(Row a, Row b, Row c, Row d, Row e, Row f, Row g) => ListAsRow (a, b, c, d, e, f, g) 
(Row a, Row b, Row c, Row d, Row e, Row f, Row g, Row h) => ListAsRow (a, b, c, d, e, f, g, h) 
(Row a, Row b, Row c, Row d, Row e, Row f, Row g, Row h, Row i) => ListAsRow (a, b, c, d, e, f, g, h, i) 
(Row a, Row b, Row c, Row d, Row e, Row f, Row g, Row h, Row i, Row l) => ListAsRow (a, b, c, d, e, f, g, h, i, l) 

class Row a => ListAsRows a where

A type that instantiate ListAsRows is a type that has a representation when is embedded inside a list

Note: we use this class for representing a list of chars as String instead of the standard list representation. Without this repr test would yield [t,e,s,r] instead of test.

For example:

>>> mapM_ Data.ByteString.Lazy.Char8.putStrLn $ repr Data.ByteString.Lazy.Char8.empty "test"
test

Methods

listRepr

Arguments

:: ByteString

column delimiter

-> [a]

list of values to represent

-> [ByteString] 

Instances

ListAsRows Bool 
ListAsRows Char 
ListAsRows Double 
ListAsRows Float 
ListAsRows Int 
ListAsRows Integer 
ListAsRows () 
ListAsRows ByteString 
(ListAsRow a, ListAsRows a) => ListAsRows [a] 
Row a => ListAsRows (Maybe a) 
(ListAsRow a, ListAsRows a) => ListAsRows (Set a) 
(Row a, Row b) => ListAsRows (a, b) 
(Row a, Row b) => ListAsRows (Map a b) 
(Row a, Row b, Row c) => ListAsRows (a, b, c) 
(Row a, Row b, Row c, Row d) => ListAsRows (a, b, c, d) 
(Row a, Row b, Row c, Row d, Row e) => ListAsRows (a, b, c, d, e) 
(Row a, Row b, Row c, Row d, Row e, Row f) => ListAsRows (a, b, c, d, e, f) 
(Row a, Row b, Row c, Row d, Row e, Row f, Row g) => ListAsRows (a, b, c, d, e, f, g) 
(Row a, Row b, Row c, Row d, Row e, Row f, Row g, Row h) => ListAsRows (a, b, c, d, e, f, g, h) 
(Row a, Row b, Row c, Row d, Row e, Row f, Row g, Row h, Row i) => ListAsRows (a, b, c, d, e, f, g, h, i) 
(Row a, Row b, Row c, Row d, Row e, Row f, Row g, Row h, Row i, Row l) => ListAsRows (a, b, c, d, e, f, g, h, i, l) 

class Show a => Row a where

A Row is something that can be expressed as a line. The output of repr' should be formatted such that it can be read and processed from the command line.

For example:

>>> IO.putStrLn $ show [1,2,3,4]
[1,2,3,4]
>>> Data.ByteString.Lazy.Char8.putStrLn $ repr' (Data.ByteString.Lazy.Char8.pack " ") [1,2,3,4]
1 2 3 4

Methods

repr'

Arguments

:: ByteString

columns delimiter

-> a

value to represent

-> ByteString 

Instances

Row Bool 
Row Char 
Row Double 
Row Float 
Row Int 
Row Integer 
Row () 
Row ByteString 
ListAsRow a => Row [a] 
Row a => Row (Maybe a) 
ListAsRow a => Row (Set a) 
(Row a, Row b) => Row (a, b) 
(Row a, Row b) => Row (Map a b) 
(Row a, Row b, Row c) => Row (a, b, c) 
(Row a, Row b, Row c, Row d) => Row (a, b, c, d) 
(Row a, Row b, Row c, Row d, Row e) => Row (a, b, c, d, e) 
(Row a, Row b, Row c, Row d, Row e, Row f) => Row (a, b, c, d, e, f) 
(Row a, Row b, Row c, Row d, Row e, Row f, Row g) => Row (a, b, c, d, e, f, g) 
(Row a, Row b, Row c, Row d, Row e, Row f, Row g, Row h) => Row (a, b, c, d, e, f, g, h) 
(Row a, Row b, Row c, Row d, Row e, Row f, Row g, Row h, Row i) => Row (a, b, c, d, e, f, g, h, i) 
(Row a, Row b, Row c, Row d, Row e, Row f, Row g, Row h, Row i, Row l) => Row (a, b, c, d, e, f, g, h, i, l) 

class Show a => Rows a where

A type that instantiate Rows is a type that can be represented as a list of rows, where typically a row is a line.

For example:

>>> mapM_ Data.ByteString.Lazy.Char8.putStrLn $ repr (Data.ByteString.Lazy.Char8.singleton '\n') [1,2,3,4]
1
2
3
4

Methods

repr

Arguments

:: ByteString

rows delimiter

-> a

value to represent

-> [ByteString] 

Return a representation of the given value as list of strings.

Instances

Rows Bool 
Rows Char 
Rows Double 
Rows Float 
Rows Int 
Rows Integer 
Rows () 
Rows ByteString 
ListAsRows a => Rows [a] 
Rows a => Rows (Maybe a) 
ListAsRows a => Rows (Set a) 
(Row a, Row b) => Rows (a, b) 
(Row a, Row b) => Rows (Map a b) 
(Row a, Row b, Row c) => Rows (a, b, c) 
(Row a, Row b, Row c, Row d) => Rows (a, b, c, d) 
(Row a, Row b, Row c, Row d, Row e) => Rows (a, b, c, d, e) 
(Row a, Row b, Row c, Row d, Row e, Row f) => Rows (a, b, c, d, e, f) 
(Row a, Row b, Row c, Row d, Row e, Row f, Row g) => Rows (a, b, c, d, e, f, g) 
(Row a, Row b, Row c, Row d, Row e, Row f, Row g, Row h) => Rows (a, b, c, d, e, f, g, h) 
(Row a, Row b, Row c, Row d, Row e, Row f, Row g, Row h, Row i) => Rows (a, b, c, d, e, f, g, h, i) 
(Row a, Row b, Row c, Row d, Row e, Row f, Row g, Row h, Row i, Row l) => Rows (a, b, c, d, e, f, g, h, i, l)