stil4m / structured-writer / 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

append : Writer -> Writer -> Writer

Join two writers into one.

bracesComma : Basics.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 : Basics.Bool -> List Writer -> Writer

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

breaked : List Writer -> Writer

Break a few writers over different lines

epsilon : Writer

Write nothing

indent : Basics.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 : Basics.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 ) -> Basics.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 : Basics.Bool -> List Writer -> Writer

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

sepBySpace : Basics.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