How to do it...

  1. Create a new project shopping-cart using the simple Stack template:
        stack new shopping-cart simple
  1. Open shopping-cart.cabal and add a dependency on the containers library in the build-depends subsection of the executable subsection:
        executable shopping-cart
         hs-source-dirs:      src
         main-is:             Main.lhs
         default-language:    Haskell2010
         build-depends:       base >= 4.7 && < 5
                       , containers
  1. Open src/Main.hs; we will add our code here. Import the module Data.Set:
        module Main where

        import Data.Set as Set
  1. Create a type to represent a book. The book contains the ISBN number, title of the book, and name of the author:
        data Book = Book { isbn :: String
                 , title :: String
                 , author :: String }
                   deriving Show
  1. Create the equality and ordering ...

Get Haskell Cookbook now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.