| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell98 |
Data.String.Interpolate.Util
Documentation
unindent :: String -> String Source
Remove indentation as much as possible while preserving relative indentation levels.
unindent is useful in combination with i to remove leading spaces that
resulted from code indentation. That way you can freely indent your string
literals without the indentation ending up in the resulting strings.
Here is an example:
>>>:set -XQuasiQuotes>>>import Data.String.Interpolate>>>import Data.String.Interpolate.Util>>>:{putStr $ unindent [i| def foo 23 end |] :} def foo 23 end
To allow this, two additional things are being done, apart from removing indentation:
- One empty line at the beginning will be removed and
- if the last newline character (
"\n") is followed by spaces, the spaces are removed.