Safe Haskell | None |
---|---|
Language | Haskell2010 |
Text.StringTemplate.Classes
Synopsis
- data SElem a
- class Show a => StringTemplateShows a where
- stringTemplateShow :: a -> String
- stringTemplateFormattedShow :: String -> a -> String
- class ToSElem a where
- toSElem :: Stringable b => a -> SElem b
- toSElemList :: Stringable b => [a] -> SElem b
- type SMap a = Map String (SElem a)
- data STShow = forall a.StringTemplateShows a => STShow a
- newtype StFirst a = StFirst {
- stGetFirst :: Maybe a
- class Monoid a => Stringable a where
- stFromString :: String -> a
- stFromByteString :: ByteString -> a
- stFromText :: Text -> a
- stToString :: a -> String
- mconcatMap :: [b] -> (b -> a) -> a
- mintercalate :: a -> [a] -> a
- mlabel :: a -> a -> a
- stShowsToSE :: (StringTemplateShows a, Stringable b) => a -> SElem b
Documentation
class Show a => StringTemplateShows a where Source #
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.
Minimal complete definition
Nothing
Methods
stringTemplateShow :: a -> String Source #
Defaults to show
.
stringTemplateFormattedShow :: String -> a -> String Source #
Defaults to _ a -> stringTemplateShow a
Instances
class ToSElem a where Source #
The ToSElem class should be instantiated for all types that can be inserted as attributes into a StringTemplate.
Minimal complete definition
Methods
toSElem :: Stringable b => a -> SElem b Source #
toSElemList :: Stringable b => [a] -> SElem b Source #
Instances
Constructors
forall a.StringTemplateShows a => STShow a |
Constructors
StFirst | |
Fields
|
Instances
class Monoid a => Stringable a where Source #
The Stringable class should be instantiated with care. Generally, the provided instances should be enough for anything.
Minimal complete definition
Methods
stFromString :: String -> a Source #
stFromByteString :: ByteString -> a Source #
stFromText :: Text -> a Source #
stToString :: a -> String Source #
mconcatMap :: [b] -> (b -> a) -> a Source #
Defaults to mconcatMap m k = foldr (mappend . k) mempty m
mintercalate :: a -> [a] -> a Source #
Defaults to (mconcat .) . intersperse
mlabel :: a -> a -> a Source #
Defaults to mlabel x y = mconcat [x, stFromString "[", y, stFromString "]"]
Instances
Stringable String Source # | |
Defined in Text.StringTemplate.Classes Methods stFromString :: String -> String Source # stFromByteString :: ByteString -> String Source # stFromText :: Text -> String Source # stToString :: String -> String Source # mconcatMap :: [b] -> (b -> String) -> String Source # mintercalate :: String -> [String] -> String Source # | |
Stringable Builder Source # | |
Defined in Text.StringTemplate.Classes Methods stFromString :: String -> Builder Source # stFromByteString :: ByteString -> Builder Source # stFromText :: Text -> Builder Source # stToString :: Builder -> String Source # mconcatMap :: [b] -> (b -> Builder) -> Builder Source # mintercalate :: Builder -> [Builder] -> Builder Source # | |
Stringable ByteString Source # | |
Defined in Text.StringTemplate.Classes Methods stFromString :: String -> ByteString Source # stFromByteString :: ByteString -> ByteString Source # stFromText :: Text -> ByteString Source # stToString :: ByteString -> String Source # mconcatMap :: [b] -> (b -> ByteString) -> ByteString Source # mintercalate :: ByteString -> [ByteString] -> ByteString Source # | |
Stringable ByteString Source # | |
Defined in Text.StringTemplate.Classes Methods stFromString :: String -> ByteString Source # stFromByteString :: ByteString0 -> ByteString Source # stFromText :: Text -> ByteString Source # stToString :: ByteString -> String Source # mconcatMap :: [b] -> (b -> ByteString) -> ByteString Source # mintercalate :: ByteString -> [ByteString] -> ByteString Source # | |
Stringable Text Source # | |
Defined in Text.StringTemplate.Classes Methods stFromString :: String -> Text Source # stFromByteString :: ByteString -> Text Source # stFromText :: Text -> Text Source # stToString :: Text -> String Source # mconcatMap :: [b] -> (b -> Text) -> Text Source # mintercalate :: Text -> [Text] -> Text Source # | |
Stringable Text Source # | |
Defined in Text.StringTemplate.Classes Methods stFromString :: String -> Text Source # stFromByteString :: ByteString -> Text Source # stFromText :: Text0 -> Text Source # stToString :: Text -> String Source # mconcatMap :: [b] -> (b -> Text) -> Text Source # mintercalate :: Text -> [Text] -> Text Source # | |
Stringable Builder Source # | |
Defined in Text.StringTemplate.Classes Methods stFromString :: String -> Builder Source # stFromByteString :: ByteString -> Builder Source # stFromText :: Text -> Builder Source # stToString :: Builder -> String Source # mconcatMap :: [b] -> (b -> Builder) -> Builder Source # mintercalate :: Builder -> [Builder] -> Builder Source # | |
Stringable Doc Source # | |
Defined in Text.StringTemplate.Classes Methods stFromString :: String -> Doc Source # stFromByteString :: ByteString -> Doc Source # stFromText :: Text -> Doc Source # stToString :: Doc -> String Source # mconcatMap :: [b] -> (b -> Doc) -> Doc Source # mintercalate :: Doc -> [Doc] -> Doc Source # | |
Stringable (Endo String) Source # | |
Defined in Text.StringTemplate.Classes Methods stFromString :: String -> Endo String Source # stFromByteString :: ByteString -> Endo String Source # stFromText :: Text -> Endo String Source # stToString :: Endo String -> String Source # mconcatMap :: [b] -> (b -> Endo String) -> Endo String Source # mintercalate :: Endo String -> [Endo String] -> Endo String Source # mlabel :: Endo String -> Endo String -> Endo String Source # |
stShowsToSE :: (StringTemplateShows a, Stringable b) => a -> SElem b Source #
This method should be used to create ToSElem instances for types defining a custom formatted show function.