- type Iteratee val seed m = seed -> val -> m (Either seed seed)
- newtype Enumerator val m = Enumerator {
- runEnumerator :: forall seed. Iteratee val seed m -> seed -> m (Either seed seed)
- fromList :: Monad m => [a] -> Enumerator a m
- newtype Hamlet url m a = Hamlet {}
- data HtmlContent
- output :: Monad m => Text -> Hamlet url m ()
- outputHtml :: Monad m => HtmlContent -> Hamlet url m ()
- outputString :: Monad m => String -> Hamlet url m ()
- outputUrl :: Monad m => url -> Hamlet url m ()
- outputUrlParams :: Monad m => (url, [(String, String)]) -> Hamlet url m ()
- outputEmbed :: Monad m => Hamlet url m () -> Hamlet url m ()
- htmlContentToText :: HtmlContent -> Text
- showUrl :: Monad m => url -> Hamlet url m String
- liftHamlet :: Monad m => m a -> Hamlet url m a
- mapH :: Monad m => (val -> Hamlet url m ()) -> Enumerator val m -> Hamlet url m ()
- condH :: Monad m => [(m Bool, Hamlet url m ())] -> Maybe (Hamlet url m ()) -> Hamlet url m ()
- maybeH :: Monad m => Maybe v -> (v -> Hamlet url m ()) -> Hamlet url m ()
- maybeH' :: Monad m => Maybe v -> (v -> Hamlet url m ()) -> Maybe (Hamlet url m ()) -> Hamlet url m ()
- printHamlet :: (url -> String) -> Hamlet url IO () -> IO ()
- hamletToText :: Monad m => (url -> String) -> Hamlet url m () -> m Text
- cdata :: HtmlContent -> HtmlContent
Generalized enumerator
newtype Enumerator val m Source
Generates a stream of values to be passed to an Iteratee
.
Enumerator | |
|
fromList :: Monad m => [a] -> Enumerator a mSource
Convert a list into an Enumerator
.
Datatypes
Hamlet
is a monad that has two features:
- It passes along a function to convert a URL to a
String
. - It keeps an
Iteratee
and a seed value so that it can output values. Output is all done through a strictText
value.
The URL to String function makes it very convenient to write templates without knowing the absolute URLs for all referenced resources. For more information on this approach, please see the web-routes package.
For efficiency, the Hamlet
monad halts execution as soon as the underlying
Iteratee
returns a Left
value. This is normally what you want; this
might cause a problem if you are relying on the side effects of a Hamlet
action. However, it is not recommended to rely on side-effects. Though a
Hamlet
monad may perform IO actions, this should only be used for
read-only behavior for efficiency.
data HtmlContent Source
Output
outputHtml :: Monad m => HtmlContent -> Hamlet url m ()Source
Outputs the given HtmlContent
, entity encoding any Unencoded
data.
outputUrl :: Monad m => url -> Hamlet url m ()Source
Uses the URL rendering function to convert the given URL to a String
and
then calls outputString
.
outputUrlParams :: Monad m => (url, [(String, String)]) -> Hamlet url m ()Source
Same as outputUrl
, but appends a query-string with given keys and
values.
outputEmbed :: Monad m => Hamlet url m () -> Hamlet url m ()Source
Only really used to ensure that the argument has the right type.
Utility functions
htmlContentToText :: HtmlContent -> TextSource
Returns HTML-ready text (ie, all entities are escaped properly).
liftHamlet :: Monad m => m a -> Hamlet url m aSource
Lift a monadic action into the Hamlet
monad.
mapH :: Monad m => (val -> Hamlet url m ()) -> Enumerator val m -> Hamlet url m ()Source
Perform the given Hamlet
action for all values generated by the given
Enumerator
.
condH :: Monad m => [(m Bool, Hamlet url m ())] -> Maybe (Hamlet url m ()) -> Hamlet url m ()Source
Checks for truth in the left value in each pair in the first argument. If a true exists, then the corresponding right action is performed. Only the first is performed. In there are no true values, then the second argument is performed, if supplied.
maybeH :: Monad m => Maybe v -> (v -> Hamlet url m ()) -> Hamlet url m ()Source
Runs the second argument with the value in the first, if available.
maybeH' :: Monad m => Maybe v -> (v -> Hamlet url m ()) -> Maybe (Hamlet url m ()) -> Hamlet url m ()Source
Runs the second argument with the value in the first, if available. Otherwise, runs the third argument, if available.
printHamlet :: (url -> String) -> Hamlet url IO () -> IO ()Source
Prints a Hamlet to standard out. Good for debugging.
hamletToText :: Monad m => (url -> String) -> Hamlet url m () -> m TextSource
Converts a Hamlet
to lazy text, using strict I/O.
cdata :: HtmlContent -> HtmlContentSource
Wrap some HtmlContent
for embedding in an XML file.