O'Reilly logo

Haskell Cookbook by Yogesh Sajanikar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

  1. Create a new project, working-with-blaze-html, with simple stack template:
        stack new working-with-blaze-html simple
  1. Add a dependency on the blaze-html library in the build-depends sub-section of the executable section:
        executable blaze-html
          hs-source-dirs:      src
          main-is:             Main.hs
          default-language:    Haskell2010
          build-depends:       base >= 4.7 && < 5
                             , blaze-html
  1. Open src/Main.hs. We will be adding our source here.
  2. Add the extension OverloadedStrings. This will enable us to work with many strings that we will use in this recipe. Also add the Main module definition:
 {-# LANGUAGE OverloadedStrings #-}
 module Main where
  1. Import blaze-html modules for creating HTML5 elements and attributes:
 import Control.Monad
 import Text.Blaze.Html5 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required