HStringTemplate-0.8.6: StringTemplate implementation in Haskell.

Safe HaskellNone
LanguageHaskell98

Text.StringTemplate.Classes

Synopsis

Documentation

data SElem a #

Constructors

STR String 
BS ByteString 
TXT Text 
STSH STShow 
SM (SMap a) 
LI [SElem a] 
SBLE a 
SNAT a 
SNull 

class Show a => StringTemplateShows a where #

The StringTemplateShows class should be instantiated for all types that are directly displayed in a StringTemplate, but take an optional format string. Each such type must have an appropriate ToSElem method defined as well.

Methods

stringTemplateShow :: a -> String #

Defaults to show.

stringTemplateFormattedShow :: String -> a -> String #

Defaults to _ a -> stringTemplateShow a

class ToSElem a where #

The ToSElem class should be instantiated for all types that can be inserted as attributes into a StringTemplate.

Minimal complete definition

toSElem

Methods

toSElem :: Stringable b => a -> SElem b #

toSElemList :: Stringable b => [a] -> SElem b #

type SMap a = Map String (SElem a) #

data STShow #

Constructors

StringTemplateShows a => STShow a 

newtype StFirst a #

Constructors

StFirst 

Fields

Instances

Functor StFirst # 

Methods

fmap :: (a -> b) -> StFirst a -> StFirst b #

(<$) :: a -> StFirst b -> StFirst a #

Eq a => Eq (StFirst a) # 

Methods

(==) :: StFirst a -> StFirst a -> Bool #

(/=) :: StFirst a -> StFirst a -> Bool #

Ord a => Ord (StFirst a) # 

Methods

compare :: StFirst a -> StFirst a -> Ordering #

(<) :: StFirst a -> StFirst a -> Bool #

(<=) :: StFirst a -> StFirst a -> Bool #

(>) :: StFirst a -> StFirst a -> Bool #

(>=) :: StFirst a -> StFirst a -> Bool #

max :: StFirst a -> StFirst a -> StFirst a #

min :: StFirst a -> StFirst a -> StFirst a #

Read a => Read (StFirst a) # 
Show a => Show (StFirst a) # 

Methods

showsPrec :: Int -> StFirst a -> ShowS #

show :: StFirst a -> String #

showList :: [StFirst a] -> ShowS #

Monoid (StFirst a) # 

Methods

mempty :: StFirst a #

mappend :: StFirst a -> StFirst a -> StFirst a #

mconcat :: [StFirst a] -> StFirst a #

class Monoid a => Stringable a where #

The Stringable class should be instantiated with care. Generally, the provided instances should be enough for anything.

Minimal complete definition

stFromString, stToString

Methods

stFromString :: String -> a #

stFromByteString :: ByteString -> a #

stFromText :: Text -> a #

stToString :: a -> String #

mconcatMap :: [b] -> (b -> a) -> a #

Defaults to mconcatMap m k = foldr (mappend . k) mempty m

mintercalate :: a -> [a] -> a #

Defaults to (mconcat .) . intersperse

mlabel :: a -> a -> a #

Defaults to mlabel x y = mconcat [x, stFromString "[", y, stFromString "]"]

Instances

Stringable String # 
Stringable ByteString # 
Stringable ByteString # 
Stringable Builder # 
Stringable Text # 
Stringable Text # 
Stringable Doc # 
Stringable Builder # 
Stringable (Endo String) # 

stShowsToSE :: (StringTemplateShows a, Stringable b) => a -> SElem b #

This method should be used to create ToSElem instances for types defining a custom formatted show function.