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

Safe HaskellSafe
LanguageHaskell98

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 Source

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

Minimal complete definition

Nothing

Instances

ListAsRow Bool Source 
ListAsRow Char Source 
ListAsRow Double Source 
ListAsRow Float Source 
ListAsRow Int Source 
ListAsRow Integer Source 
ListAsRow () Source 
ListAsRow ByteString Source 
ListAsRow a => ListAsRow [a] Source 
Row a => ListAsRow (Maybe a) Source 
ListAsRow a => ListAsRow (Set a) Source 
(Row a, Row b) => ListAsRow (a, b) Source 
(Row a, Row b) => ListAsRow (Map a b) Source 
(Row a, Row b, Row c) => ListAsRow (a, b, c) Source 
(Row a, Row b, Row c, Row d) => ListAsRow (a, b, c, d) Source 
(Row a, Row b, Row c, Row d, Row e) => ListAsRow (a, b, c, d, e) Source 
(Row a, Row b, Row c, Row d, Row e, Row f) => ListAsRow (a, b, c, d, e, f) Source 
(Row a, Row b, Row c, Row d, Row e, Row f, Row g) => ListAsRow (a, b, c, d, e, f, g) Source 
(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) Source 
(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) Source 
(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) Source 

class Row a => ListAsRows a where Source

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

Minimal complete definition

Nothing

Methods

listRepr Source

Arguments

:: ByteString

column delimiter

-> [a]

list of values to represent

-> [ByteString] 

Instances

ListAsRows Bool Source 
ListAsRows Char Source 
ListAsRows Double Source 
ListAsRows Float Source 
ListAsRows Int Source 
ListAsRows Integer Source 
ListAsRows () Source 
ListAsRows ByteString Source 
(ListAsRow a, ListAsRows a) => ListAsRows [a] Source 
Row a => ListAsRows (Maybe a) Source 
(ListAsRow a, ListAsRows a) => ListAsRows (Set a) Source 
(Row a, Row b) => ListAsRows (a, b) Source 
(Row a, Row b) => ListAsRows (Map a b) Source 
(Row a, Row b, Row c) => ListAsRows (a, b, c) Source 
(Row a, Row b, Row c, Row d) => ListAsRows (a, b, c, d) Source 
(Row a, Row b, Row c, Row d, Row e) => ListAsRows (a, b, c, d, e) Source 
(Row a, Row b, Row c, Row d, Row e, Row f) => ListAsRows (a, b, c, d, e, f) Source 
(Row a, Row b, Row c, Row d, Row e, Row f, Row g) => ListAsRows (a, b, c, d, e, f, g) Source 
(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) Source 
(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) Source 
(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) Source 

class Show a => Row a where Source

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

For example:

>>> 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

Minimal complete definition

Nothing

Methods

repr' Source

Arguments

:: ByteString

columns delimiter

-> a

value to represent

-> ByteString 

Instances

Row Bool Source 
Row Char Source 
Row Double Source 
Row Float Source 
Row Int Source 
Row Integer Source 
Row () Source 
Row ByteString Source 
ListAsRow a => Row [a] Source 
Row a => Row (Maybe a) Source 
ListAsRow a => Row (Set a) Source 
(Row a, Row b) => Row (a, b) Source 
(Row a, Row b) => Row (Map a b) Source 
(Row a, Row b, Row c) => Row (a, b, c) Source 
(Row a, Row b, Row c, Row d) => Row (a, b, c, d) Source 
(Row a, Row b, Row c, Row d, Row e) => Row (a, b, c, d, e) Source 
(Row a, Row b, Row c, Row d, Row e, Row f) => Row (a, b, c, d, e, f) Source 
(Row a, Row b, Row c, Row d, Row e, Row f, Row g) => Row (a, b, c, d, e, f, g) Source 
(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) Source 
(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) Source 
(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) Source 

class Show a => Rows a where Source

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

Minimal complete definition

Nothing

Methods

repr Source

Arguments

:: ByteString

rows delimiter

-> a

value to represent

-> [ByteString] 

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

Instances

Rows Bool Source 
Rows Char Source 
Rows Double Source 
Rows Float Source 
Rows Int Source 
Rows Integer Source 
Rows () Source 
Rows ByteString Source 
ListAsRows a => Rows [a] Source 
Rows a => Rows (Maybe a) Source 
ListAsRows a => Rows (Set a) Source 
(Row a, Row b) => Rows (a, b) Source 
(Row a, Row b) => Rows (Map a b) Source 
(Row a, Row b, Row c) => Rows (a, b, c) Source 
(Row a, Row b, Row c, Row d) => Rows (a, b, c, d) Source 
(Row a, Row b, Row c, Row d, Row e) => Rows (a, b, c, d, e) Source 
(Row a, Row b, Row c, Row d, Row e, Row f) => Rows (a, b, c, d, e, f) Source 
(Row a, Row b, Row c, Row d, Row e, Row f, Row g) => Rows (a, b, c, d, e, f, g) Source 
(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) Source 
(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) Source 
(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) Source