In [1]:
2+3


5

In [2]:
{-# LANGUAGE OverloadedStrings #-}

In [3]:
import Control.Monad (forM_)

In [4]:
import Text.Blaze.Html5 as H

In [5]:
import Text.Blaze.Html5.Attributes as A

In [7]:
numbers :: Int -> Html
numbers n = docTypeHtml $ do
     H.head $ do
         H.title "Natural numbers"
     body $ do
         p "A list of natural numbers:"
         ul $ forM_ [1 .. n] (li . toHtml)


Redundant do
Found:
do H.title "Natural numbers"
Why Not:
H.title "Natural numbers"

In [8]:
numbers 3


Natural numbers

A list of natural numbers:

  • 1
  • 2
  • 3

In [13]:
import Text.Blaze.Renderer.Pretty
import Text.Blaze.Renderer.String

In [14]:
Text.Blaze.Renderer.String.renderHtml $ numbers 3


"<!DOCTYPE HTML>\n<html><head><title>Natural numbers</title></head><body><p>A list of natural numbers:</p><ul><li>1</li><li>2</li><li>3</li></ul></body></html>"

In [ ]: