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 working-with-set using the simple Stack template:
        stack new working-with-set simple
  1. In the project folder, open the working-with-set.cabal file. Add the new dependency containers in the subsection build-depends of section executable:
        executable working-with-set
          hs-source-dirs:      src
          main-is:             Main.lhs
         default-language:    Haskell2010
         build-depends:       base >= 4.7 && < 5
                            , Containers

The containers library is a commonly used library that implements containers such as set, map, and so on.

  1. Open src/Main.hs for editing. We will work with sets in this file:
        module Main where
  1. Import Data.Set for using set and related functions:
        import Data.Set as S
  1. Write main; we will write set examples in the main function: ...

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