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

PortabilityRequires OverloadedStrings
StabilityStable
MaintainerBas van Dijk <v.dijk.bas@gmail.com>

Data.String.Combinators

Contents

Description

Note that I am thinking about putting some of the combinators ((<>), (<+>), ($$) and maybe more) in a type class. This allows the 'pretty' package to use this package.

Synopsis

Combining

(<>) :: Monoid s => s -> s -> sSource

Put two string-likes besides eachother.

Note that <> is just a 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.

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

List version of <>.

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

List version of <+>.

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

List version of $$.

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

punctuate p [d1, ... dn] = [d1 <> p, d2 <> p, ... dn-1 <> p, dn].

Wrapping in delimiters

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

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

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

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

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

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

This function is supposed to be used infix as in:

(precedence >= 10) `thenParen` ("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 Show-able value to a string. fromShow = fromString . show

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.