HStringTemplate-0.6.8: StringTemplate implementation in Haskell.

Safe HaskellNone

Text.StringTemplate.Classes

Synopsis

Documentation

data SElem a

Constructors

STR String 
BS ByteString 
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.

Methods

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

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

Instances

ToSElem Bool 
ToSElem Char 
ToSElem Double 
ToSElem Float 
ToSElem Int 
ToSElem Integer 
Data a => ToSElem a 
ToSElem ByteString 
ToSElem ByteString 
ToSElem CalendarTime 
ToSElem TimeDiff 
ToSElem Text 
ToSElem Text 
ToSElem LocalTime 
ToSElem ZonedTime 
ToSElem TimeOfDay 
ToSElem TimeZone 
ToSElem UTCTime 
ToSElem Day 
ToSElem a => ToSElem [a] 
(Integral a, Show a) => ToSElem (Ratio a) 
(ToSElem a, Foldable t) => ToSElem (t a) 
ToSElem a => ToSElem (Maybe a) 
(ToSElem a, ToSElem b) => ToSElem (a, b) 
(ToSElem a, Ix i) => ToSElem (Array i a) 
ToSElem a => ToSElem (Map String a) 
(ToSElem a, ToSElem b, ToSElem c) => ToSElem (a, b, c) 
(ToSElem a, ToSElem b, ToSElem c, ToSElem d) => ToSElem (a, b, c, d) 
(ToSElem a, ToSElem b, ToSElem c, ToSElem d, ToSElem e) => ToSElem (a, b, c, d, e) 
(ToSElem a, ToSElem b, ToSElem c, ToSElem d, ToSElem e, ToSElem f) => ToSElem (a, b, c, d, e, f) 
(ToSElem a, ToSElem b, ToSElem c, ToSElem d, ToSElem e, ToSElem f, ToSElem g) => ToSElem (a, b, c, d, e, f, g) 
(ToSElem a, ToSElem b, ToSElem c, ToSElem d, ToSElem e, ToSElem f, ToSElem g, ToSElem h) => ToSElem (a, b, c, d, e, f, g, h) 
(ToSElem a, ToSElem b, ToSElem c, ToSElem d, ToSElem e, ToSElem f, ToSElem g, ToSElem h, ToSElem i) => ToSElem (a, b, c, d, e, f, g, h, i) 
(ToSElem a, ToSElem b, ToSElem c, ToSElem d, ToSElem e, ToSElem f, ToSElem g, ToSElem h, ToSElem i, ToSElem j) => ToSElem (a, b, c, d, e, f, g, h, i, j) 

type SMap a = Map String (SElem a)

data STShow

Constructors

forall a . StringTemplateShows a => STShow a 

newtype StFirst a

Constructors

StFirst 

Fields

stGetFirst :: Maybe a
 

Instances

Functor StFirst 
Eq a => Eq (StFirst a) 
Ord a => Ord (StFirst a) 
Read a => Read (StFirst a) 
Show a => Show (StFirst a) 
Monoid (StFirst a) 

class Stringable a where

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

Methods

stFromString :: String -> a

stFromByteString :: ByteString -> 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 = smconcat [x, stFromString [, y, stFromString ]]

smempty :: a

Just mempty. Here to avoid orphan instances

smappend :: a -> a -> a

Just mappend. Here to avoid orphan instances

smconcat :: [a] -> a

Just mconcat. Here to avoid orphan instances

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.