-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Polymorphic functions to build and combine stringlike values -- -- string-combinators provides handy polymorphic functions to build and -- combine string-like values. -- -- All functions are polymorphic in their string-like type but usually -- have a Monoid or IsString constraint. @package string-combinators @version 0.4 -- | 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. module Data.String.Combinators -- | Put two string-likes besides eachother. -- -- Note that <> is just a synonym for mappend. (<>) :: (Monoid s) => s -> s -> s -- | mid m x y Puts x and y around m. -- -- Note that: mid m x y = between x y m. mid :: (Monoid s) => s -> (s -> s -> s) -- | Put two string-likes besides eachother separated by a space. (<+>) :: (Monoid s, IsString s) => s -> s -> s -- | Put two string-likes above eachother. ($$) :: (Monoid s, IsString s) => s -> s -> s -- | Combine the string-likes with a given function. intercalate :: (Monoid s) => (s -> s -> s) -> [s] -> s -- | List version of <>. -- -- Note that hcat = intercalate (<>). hcat :: (Monoid s) => [s] -> s -- | List version of <+>. -- -- Note that hsep = intercalate (<+>). hsep :: (Monoid s, IsString s) => [s] -> s -- | List version of $$. vcat :: (Monoid s, IsString s) => [s] -> s -- | punctuate p [d1, ... dn] = [d1 <> p, d2 -- <> p, ... dn-1 <> p, dn]. -- -- Idea and implementation taken from pretty: punctuate :: (Monoid s) => s -> [s] -> [s] -- | between b c s wraps the string-like s between -- b and c. between :: (Monoid s) => s -> s -> (s -> s) -- | Wrap a string-like in (...). paren :: (Monoid s, IsString s) => s -> s -- | Like showParen conditionally wraps a string in (...) -- -- This function is supposed to be used infix as in: -- --
--   (precedence >= 10) `thenParen` ("fun" <+> "arg")
--   
thenParen :: (Monoid s, IsString s) => Bool -> s -> s -- | Wrap a string-like in [...]. brackets :: (Monoid s, IsString s) => s -> s -- | Wrap a string-like in {...}. braces :: (Monoid s, IsString s) => s -> s -- | Wrap a string-like in <...>. angleBrackets :: (Monoid s, IsString s) => s -> s -- | Wrap a string-like in '...'. quotes :: (Monoid s, IsString s) => s -> s -- | Wrap a string-like in "...". doubleQuotes :: (Monoid s, IsString s) => s -> s -- | Convert a character to a string-like. char :: (IsString s) => Char -> s -- | A ';' character. semi :: (IsString s) => s -- | A : character. colon :: (IsString s) => s -- | A ',' character. comma :: (IsString s) => s -- | A ' ' character. space :: (IsString s) => s -- | A '\n' character. newline :: (IsString s) => s -- | A '=' character. equals :: (IsString s) => s -- | A '(' character. lparen :: (IsString s) => s -- | A ')' character. rparen :: (IsString s) => s -- | A '[' character. lbrack :: (IsString s) => s -- | A ']' character. rbrack :: (IsString s) => s -- | A '{' character. lbrace :: (IsString s) => s -- | A '}' character. rbrace :: (IsString s) => s -- | A '<' character. labrack :: (IsString s) => s -- | A '>' character. rabrack :: (IsString s) => s -- | Convert a Show-able value to a string. fromShow = fromString . -- show fromShow :: (Show a, IsString s) => a -> s -- | Convert an Int to a string-like. int :: (IsString s) => Int -> s -- | Convert an Integer to a string-like. integer :: (IsString s) => Integer -> s -- | Convert a Float to a string-like. float :: (IsString s) => Float -> s -- | Convert a Double to a string-like. double :: (IsString s) => Double -> s -- | Convert a Rational to a string-like. rational :: (IsString s) => Rational -> s