| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Xrefcheck.Util.Interpolate
Synopsis
- interpolateIndentF :: HasCallStack => Int -> Builder -> Builder
- interpolateBlockListF :: HasCallStack => Buildable a => NonEmpty a -> Builder
- interpolateBlockListF' :: HasCallStack => Text -> (a -> Builder) -> NonEmpty a -> Builder
- interpolateUnlinesF :: HasCallStack => Buildable a => NonEmpty a -> Builder
Documentation
The blockListF and indentF frunctions from fmt add a trailing newline, which makes them unsuitable for string interpolation.
Consider this case:
> [int||
> aaa
> #{indentF 2 "bbb"}
> ccc
> |]
One would reasonably expect this to produce:
> aaa
> bbb
> ccc
But, in reality, it produces:
> aaa
> bbb
>
> ccc
This module introduces versions of these functions that do not produce a trailing newline
and can therefore be safely used in string interpolation.
interpolateIndentF :: HasCallStack => Int -> Builder -> Builder Source #
Like Fmt.indentF, but strips trailing spaces and does not add a trailing newline.
>>>import Fmt>>>indentF 2 "a\n\nb"" a\n \n b\n"
>>>interpolateIndentF 2 "a\n\nb"" a\n\n b"
interpolateBlockListF :: HasCallStack => Buildable a => NonEmpty a -> Builder Source #
Like Fmt.blockListF, but strips trailing spaces and does not add a trailing newline.
interpolateBlockListF' :: HasCallStack => Text -> (a -> Builder) -> NonEmpty a -> Builder Source #
Like Fmt.blockListF', but strips trailing spaces and does not add a trailing newline.
interpolateUnlinesF :: HasCallStack => Buildable a => NonEmpty a -> Builder Source #
Like Fmt.unlinesF, but strips trailing spaces and does not add a trailing newline.