Skip to content

WebGear User Guide


This guide is designed to help you get started with WebGear. It follows a tutorial style; if you are looking for reference material, see the API documentation.


This guide assumes that you have a good idea of how HTTP APIs work in general. You also need a good understanding of Haskell programming language features such as type classes, monads, monad transformers etc.

WebGear uses a small set of GHC Haskell features that are generally considered advanced. But this guide does not assume that you are an expert in these. All such features will be explained in this guide.

However, it is assumed that you understand some basic GHC language extensions such as OverloadedStrings, TypeApplications, and FlexibleContexts. A cursory understanding of QuasiQuotes is useful but not essential.

You need a working Haskell development environment with either stack or cabal. If you are using cabal, use GHC version 8.8.4.


Let us set up a project first.

Create a project

stack new webgear-guide simple --resolver lts-16.12
cd webgear-guide
cabal update
mkdir webgear-guide
cd webgear-guide
cabal init --application-dir=src

Adjust dependencies

Edit webgear-guide.cabal and add the following dependencies under build-depends section:

build-depends: base                  ==
             , webgear-server        ==0.2.0
             , mtl                   ==2.2.2
             , wai                   ==
             , warp                  ==3.3.13
             , text                  ==
             , bytestring            ==
             , utf8-string           ==
             , time                  ==1.9.3
             , unordered-containers  ==
             , hashable              ==
             , aeson                 ==
             , http-types            ==0.12.3

In addition to this, if you are using stack, add the following to stack.yaml:

- webgear-server-0.2.0
stack build
cabal build


If this is the first time you are setting up the project, it will take a long time to download and build the dependencies. Subsequent builds will use cached artifacts and will be faster.