Book Image

Haskell Data Analysis Cookbook

By : Nishant Shukla
Book Image

Haskell Data Analysis Cookbook

By: Nishant Shukla

Overview of this book

Table of Contents (19 chapters)
Haskell Data Analysis Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Presenting results in an HTML web page


Sharing data online is one of the quickest ways to reach a broad audience. However, typing data into HTML directly can be time consuming. This recipe will generate a web page using the Blaze Haskell library to present data results. For more documentation and tutorials, visit the project webpage at http://jaspervdj.be/blaze/.

Getting ready

Install the Blaze package from cabal using the following command:

$ cabal install blaze-html

How to do it…

In a new file called Main.hs, perform the following steps:

  1. Import all the necessary libraries as follows:

    {-# LANGUAGE OverloadedStrings #-}
    
    import Control.Monad (forM_)
    import Text.Blaze.Html5
    import qualified Text.Blaze.Html5 as H
    import Text.Blaze.Html.Renderer.Utf8 (renderHtml)
    import qualified Data.ByteString.Lazy as BSL
  2. Convert the list of string into an HTML unordered list as shown in the following code snippet:

    dataInList :: Html -> [String] -> Html
    dataInList label items = docTypeHtml $ do    
      H.head...