A line of text (does not contain newlines).
Moduleturtle-1.6.2Haskell2010
Turtle.Line
- 2 types
- 5 values
- Packageturtle-1.6.2
- Exports7
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceLine.hs
Convert a line to a text value.
Split text into lines. The inverse of linesToText.
Merge lines into a single text value.
Try to convert a text value into a line. Precondition (checked): the argument does not contain newlines.
Convert a text value into a line. Precondition (unchecked): the argument does not contain newlines.
The NewlineForbidden exception is thrown when you construct a Line
using an overloaded string literal or by calling fromString explicitly
and the supplied string contains newlines. This is a programming error to
do so: if you aren't sure that the input string is newline-free, do not
rely on the IsString Line instance.
When debugging, it might be useful to look for implicit invocations of fromString for Line:
>>> sh (do { line <- "Hello\nWorld"; echo line })
*** Exception: NewlineForbiddenIn the above example, echo expects its argument to be a Line, thus
line :: Line. Since we bind line in Shell, the string literal
"Hello\nWorld" has type . The
Shell LineIsString ( instance delegates the construction of a
Line to the Shell Line)IsString Line instance, where the exception is thrown.
To fix the problem, use textToLines:
>>> sh (do { line <- select (textToLines "Hello\nWorld"); echo line })
Hello
WorldInstances2Show, Exception
Show NewlineForbiddenDefined in turtle-1.6.2 · Turtle.LineException NewlineForbiddenDefined in turtle-1.6.2 · Turtle.Line