HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleinterpolate-0.2.1Haskell2010

Data.String.Interpolate.Util

  • 1 value
valueunindent :: String -> String
#

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:

Example4 expressions
:set -XQuasiQuotesimport Data.String.Interpolateimport Data.String.Interpolate.Util:{ putStr $ unindent [i|     def foo       23     end   |]:}def foo  23end

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.