PyF-0.11.0.0: Quasiquotations for a python like interpolated string formatter
Safe HaskellNone
LanguageHaskell2010

PyF

Description

A lot of quasiquoters to format and interpolate string expression

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, no interpolation neither 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 line 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 wrap the multiline string with fromString.

addTrim :: Config -> Config Source #

Add indentation trimming to a configuration.

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

Enable formatting