Question

I'm working with blaze-html. I'm finally mostly being able to wrap my head around how to use it, but some of the monads and transformations really trip me up all the time. But here is one particular stumbling block (out of a great many, but I'll leave for another day getting from here to Happstack's Response and ServerPart monads).

If I'm wanting to attach string text to a paragraph, I have to use this function (from Text.Blaze.Html5):

p . toHtml :: ToMessage a => a -> Html

All, well and good, except...

toHtml :: ToMarkup a => a -> Markup
p :: Html -> Html

I've searched the documentation to the best of my ability, and I cannot see how the Markup monad and the Html monad are associated with one another. How do I work through all of the types and typeclasses?

Was it helpful?

Solution

They are synonyms (i.e. they are the same type), as shown in the documentation.

Also, it is not correct to call these types monads. They are just types. They are, however, constructed from a monad (MarkupM).

As a quick check, something can be called a monad if it is a type parameterised by another type (has kind * -> *). This is a necessary (but not sufficient) condition.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top