Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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
- class Show a => ListAsRow a where
- listRepr' :: ByteString -> [a] -> ByteString
- class Row a => ListAsRows a where
- listRepr :: ByteString -> [a] -> [ByteString]
- class Show a => Row a where
- repr' :: ByteString -> a -> ByteString
- class Show a => Rows a where
- repr :: ByteString -> a -> [ByteString]
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
Nothing
listRepr' :: ByteString -> [a] -> ByteString Source #
Instances
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
Nothing
:: ByteString | column delimiter |
-> [a] | list of values to represent |
-> [ByteString] |
Instances
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
Nothing
:: ByteString | columns delimiter |
-> a | value to represent |
-> ByteString |
Instances
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
Nothing
:: ByteString | rows delimiter |
-> a | value to represent |
-> [ByteString] |
Return a representation of the given value as list of strings.