Copyright | (c) 2019-2020 Vaclav Svejcar |
---|---|
License | BSD-3-Clause |
Maintainer | vaclav.svejcar@gmail.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Module containing bunch of useful functions for working with text.
Documentation
Working with text lines
Maps given function over individual lines of the given text.
>>>
mapLines ("T: " <>) "foo zz\nbar"
"T: foo zz\nT: bar"
Similar to unlines
, but does not automatically adds n
at the end
of the text. Advantage is that when used together with toLines
, it doesn't
ocassionaly change the newlines ad the end of input text:
>>>
fromLines . toLines $ "foo\nbar"
"foo\nbar"
>>>
fromLines . toLines $ "foo\nbar\n"
"foo\nbar\n"
Other examples:
>>>
fromLines []
""
>>>
fromLines ["foo"]
"foo"
>>>
fromLines ["first", "second"]
"first\nsecond"
>>>
fromLines ["first", "second", ""]
"first\nsecond\n"
Similar to lines
, but does not drop trailing newlines from output.
Advantage is that when used together with fromLines
, it doesn't ocassionaly
change the newlines ad the end of input text:
>>>
fromLines . toLines $ "foo\nbar"
"foo\nbar"
>>>
fromLines . toLines $ "foo\nbar\n"
"foo\nbar\n"
Other examples:
>>>
toLines ""
[]
>>>
toLines "first\nsecond"
["first","second"]
>>>
toLines "first\nsecond\n"
["first","second",""]