string-combinators-0.6.0.5: Polymorphic functions to build and combine stringlike values

MaintainerBas van Dijk <v.dijk.bas@gmail.com>
Safe HaskellSafe

Data.String.Combinators

Contents

Description

 

Synopsis

Combining

(<>) :: Monoid m => m -> m -> m

An infix synonym for mappend.

mid :: Monoid s => s -> s -> s -> sSource

mid m x y Puts x and y around m.

Note that: mid m x y = between x y m.

(<+>) :: (Monoid s, IsString s) => s -> s -> sSource

Put two string-likes besides eachother separated by a space.

($$) :: (Monoid s, IsString s) => s -> s -> sSource

Put two string-likes above eachother (separated by a newline).

intercalate :: Monoid s => (s -> s -> s) -> [s] -> sSource

Combine the string-likes with a given function.

intercalate f [s1, ... sn] = s1 `f` (s2 `f` (... (sn-1 `f` sn)))

hcat :: Monoid s => [s] -> sSource

List version of <>.

Note that: hcat = intercalate (<>).

unwords :: (Monoid s, IsString s) => [s] -> sSource

List version of <+>.

Note that: unwords = intercalate (<+>).

unlines :: (Monoid s, IsString s) => [s] -> sSource

List version of $$.

Note that: unlines = foldr ($$) mempty

punctuate :: Monoid s => s -> [s] -> [s]Source

punctuate p [s1, ... sn] = [s1 <> p, s2 <> p, ... sn-1 <> p, sn].

(Idea and implementation taken from the pretty package.)

Wrapping in delimiters

between :: Monoid s => s -> s -> s -> sSource

between b c s wraps the string-like s between b and c.

parens :: (Monoid s, IsString s) => s -> sSource

Wrap a string-like in (...).

thenParens :: (Monoid s, IsString s) => Bool -> s -> sSource

Like showParen conditionally wraps a string-like in (...)

This function is supposed to be used infix as in:

(precedence >= 10) `thenParens` ("fun" <+> "arg")

brackets :: (Monoid s, IsString s) => s -> sSource

Wrap a string-like in [...].

braces :: (Monoid s, IsString s) => s -> sSource

Wrap a string-like in {...}.

angleBrackets :: (Monoid s, IsString s) => s -> sSource

Wrap a string-like in <...>.

quotes :: (Monoid s, IsString s) => s -> sSource

Wrap a string-like in '...'.

doubleQuotes :: (Monoid s, IsString s) => s -> sSource

Wrap a string-like in "...".

From characters

char :: IsString s => Char -> sSource

Convert a character to a string-like.

semi :: IsString s => sSource

A ';' character.

colon :: IsString s => sSource

A : character.

comma :: IsString s => sSource

A ',' character.

space :: IsString s => sSource

A ' ' character.

newline :: IsString s => sSource

A '\n' character.

equals :: IsString s => sSource

A '=' character.

lparen :: IsString s => sSource

A '(' character.

rparen :: IsString s => sSource

A ')' character.

lbrack :: IsString s => sSource

A '[' character.

rbrack :: IsString s => sSource

A ']' character.

lbrace :: IsString s => sSource

A '{' character.

rbrace :: IsString s => sSource

A '}' character.

labrack :: IsString s => sSource

A '<' character.

rabrack :: IsString s => sSource

A '>' character.

From showable values

fromShow :: (Show a, IsString s) => a -> sSource

Convert a Showable value to a string-like.

int :: IsString s => Int -> sSource

Convert an Int to a string-like.

integer :: IsString s => Integer -> sSource

Convert an Integer to a string-like.

float :: IsString s => Float -> sSource

Convert a Float to a string-like.

double :: IsString s => Double -> sSource

Convert a Double to a string-like.

rational :: IsString s => Rational -> sSource

Convert a Rational to a string-like.