In a previous article, we discussed the interactive exploration of network APIs with the Haskell packages aeson, lens, and wreq. With the addition of HTML support in playgrounds in Haskell for Mac 1.2.1, we can take this further by adding HTML composition.

For example, using the widely used blaze-html package, which comes bundled with Haskell for Mac, we can grab the icon of the Haskell for Mac website and add some text with a link as follows.

The resulting HTML document gets rendered in the playground using the system renderer. This provides the same rapid feedback and exploration-friendly environment that we are used to from working with graphics in Haskell playgrounds.

For a more complex example, let's combine HTML composition with the processing of a JSON response from a network endpoint (here, for simplicity, just We grab the JSON, parse it, and display the result in a HTML document.

The HTML document includes Twitter's Bootstrap framework. Due to the use of the system renderer, even complex CSS and JavaScript is handled properly. In fact, the popover for HTML playground results embeds a fully-fledged, interactive web view; i.e., the core of the Safari browser.

To try this for yourself, just download our example project: