PyF-0.11.3.0: Quasiquotations for a python like interpolated string formatter
Safe HaskellSafe-Inferred
LanguageHaskell2010

PyF

Description

A lot of quasiquoters to format and interpolate string expressions.

Synopsis

Documentation

fmt :: QuasiQuoter Source #

Generic formatter, can format an expression to any t as long as t is an instance of IsString.

fmtTrim :: QuasiQuoter Source #

Format with whitespace trimming.

str :: QuasiQuoter Source #

Multiline string, no interpolation.

strTrim :: QuasiQuoter Source #

Multiline string, no interpolation, but does indentation trimming.

raw :: QuasiQuoter Source #

Raw string, neither interpolation nor escaping is performed.

module PyF.Class

Whitespace utilities

trimIndent :: String -> String Source #

Removes the trailing whitespace of a string.

  • First line is ignored if it only contains whitespaces
  • All other line common indentation is removed, ignoring lines with only whitespaces.
>>> trimIndent "\n   hello\n   - a\n   - b\n   "
"hello\n- a\n- b\n"

See fmtTrim for a quasiquoter with this behavior.

Configuration

mkFormatter :: String -> Config -> QuasiQuoter Source #

Build a formatter. See the Config type for details, as well as fmtConfig and strConfig for examples.

defaultConfig :: Config Source #

This is an empty configuration. No formatting, no post processing

fmtConfig :: Config Source #

The config for fmt.

strConfig :: Config Source #

Configuration for str. It just wraps the multiline string with fromString.

addTrim :: Config -> Config Source #

Add indentation trimming to a configuration.

addFormatting :: (Char, Char) -> Config -> Config Source #

Enable formatting.