stil4m/structured-writer/1.0.2

NOTE: the latest version is 1.0.3

StructuredWriter

Write structured strings

Types

type Writer

Opaque type which holds the data to be writter

Write

write : Writer -> String

Transform a writer to a string

Utils

Join two writers into one.

bracesComma : Bool -> List Writer -> Writer

Join writers with commans, enclosed with braces. Puts all things on a new line if the first argument is True.

bracketsComma : Bool -> List Writer -> Writer

Join writers with commans, enclosed with brackets. Puts all things on a new line if the first argument is True.

Break a few writers over different lines

Write nothing

indent : Int -> Writer -> Writer

Add indentation of n spaces

write (indent 2 (string "foo")) == "  foo"
join : List Writer -> Writer

Join a bunch of writers into one.

maybe : Maybe Writer -> Writer

Write something if it is present

parensComma : Bool -> List Writer -> Writer

Join writers with commans, enclosed with parens. Puts all things on a new line if the first argument is True.

sepBy : ( String, String, String ) -> Bool -> List Writer -> Writer

Join writers with the second value in the tuple and enclose with the first and last. Puts all things on a new line if the second argument is True.

write (sepBy ( "<", "-", ">" ) False [ string "a", string "b" ]) == "<a,b>"
sepByComma : Bool -> List Writer -> Writer

Join writers with commas. Puts all things on a new line if the first argument is True.

sepBySpace : Bool -> List Writer -> Writer

Join writers with spaces. Puts all things on a new line if the first argument is True.

spaced : List Writer -> Writer

Join a few writers with spaces

string : String -> Writer

Write a literal string