How to do it...

  1. Create a new project priority-queue with the default Stack template:
        stack new priority-queue
  1. Delete the src/Lib.hs file. Create a directory src/Data/ and create a new file src/Data/PriorityQueue.hs. We will add implementation of priority queue here.
  2. Open priority-queue.cabal. Remove Lib from the exposed-modules subsection from the library section. Replace it with our new Data.PriorityQueue module:
        library
          hs-source-dirs:      src
          exposed-modules:     Data.PriorityQueue
          build-depends:       base >= 4.7 && < 5
          default-language:    Haskell2010
  1. Open src/Data/PriorityQueue.hs. We will implement the priority queue here.
  1. Add the module definition for Data.PriorityQueue:
        module Data.PriorityQueue where
  1. Let's define the Queue as a sum type. ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.