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 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. ...

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