Dedent is a library for improving readability of multi-line string constants in code:
> More precisely, on an input string, Dedent does the following:
For example:
let string =
{|
> a
> b
> c
|} |> Dedent.stringThat yields the string "a\n b\n c".
Use Dedent.lines to dedent and return a list of lines rather than a string. For the above example, Dedent.lines yields:
[ "a"; " b"; " c" ]Each of the aspects of Dedent's input handling is optional. You don't have to use a line prefix. This yields the same string:
let string =
{|
a
b
c
|} |> Dedent.stringYou don't have to indent. This yields the same string:
let string =
{|
a
b
c
|} |> Dedent.stringYou don't have to put delimiters on their own lines. This yields the same string:
let string =
{|a
b
c|} |> Dedent.stringThere is also an extension syntax, [%string_dedent], that is a variant of [%string] that applies [Dedent.string] to its input before substitution. For example:
let bar = "BAR" in
let string =
[%string_dedent
{|
> foo
> %{bar}
|}]
inThat yields the string "foo\n BAR".