HORIZON HASKELLDocslts/ghc-10.0.xfc4e5982026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11

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.