In this recipe, we will create a shopping cart for books. The books are uniquely identified by ISBN numbers. If we add the same item in the shopping cart, we should be able to update the existing item or insert a new item in the shopping cart. We will use set as a container for shopping items.
Shopping cart as a set
How to do it...
- Create a new project shopping-cart using the simple Stack template:
stack new shopping-cart simple
- 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 ...