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, session-in-snap, with a simple stack template:
        stack new session-in-snap simple
  1. Add a dependency on the snap-core library in the build-depends subsection of the executable section. Add the other libraries necessary for working with Snap:
  executable session-in-snap
    hs-source-dirs:      src
    main-is:             Main.hs
    default-language:    Haskell2010
    build-depends:       base >= 4.7 && < 5
                       , snap-core
                       , snap-server
                       , snap
                       , lens
                       , bytestring
                       , text
  1. Use the following command to solve the constraints within the current resolver. For this recipe, we have used lts-9.1 as a resolver:
  stack --resolver lts-9.1 solver --update-config
  1. Open src/Main.hs. We will add our source here. Enable the GHC extensions, OverloadedStrings

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