Spock: Another Haskell web framework for rapid development

[ bsd3, library, web ] [ Propose Tags ]

This toolbox provides everything you need to get a quick start into web hacking with haskell:

A tutorial is available at spock.li

[Skip to Readme]
Versions [RSS] [faq],,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, (info)
Dependencies aeson (>=0.7), base (==4.*), base64-bytestring (>=1.0), bytestring (>=0.10), case-insensitive (>=1.1), containers (>=0.5), directory (>=1.2), focus (>=0.1), hashable (>=1.2), http-types (>=0.8), hvect (>=0.2), list-t (>=0.4), monad-control (>=1.0), mtl (>=2.1), old-locale (>=1.0), path-pieces (>=0.1.4), random (>=1.0), reroute (==0.3.*), resource-pool (>=0.2), resourcet (>=0.4), stm (>=2.4), stm-containers (==0.2.*), text (>=, time (>=1.4), transformers (>=0.3), transformers-base (>=0.4), unordered-containers (>=0.2), vault (>=0.3), wai (>=3.0), wai-extra (>=3.0), warp (>=3.0) [details]
License BSD-3-Clause
Copyright (c) 2013 - 2015 Alexander Thiemann
Author Alexander Thiemann <mail@athiemann.net>
Maintainer Alexander Thiemann <mail@athiemann.net>
Revised Revision 1 made by HerbertValerioRiedel at 2020-04-11T15:39:20Z
Category Web
Home page http://www.spock.li
Bug tracker https://github.com/agrafix/Spock/issues
Source repo head: git clone git://github.com/agrafix/Spock.git
Uploaded by AlexanderThiemann at 2015-08-12T13:25:05Z
Distributions NixOS:
Downloads 47837 total (282 in the last 30 days)
Rating 2.75 (votes: 7) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2015-08-12 [all 1 reports]




Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

For package maintainers and hackage trustees


Readme for Spock-

[back to package description]


Build Status

Hackage Deps

For more information and tutorials, visit spock.li


Hackage: Spock Tutorial: Spock Tutorial

Another Haskell web framework for rapid development: This toolbox provides everything you need to get a quick start into web hacking with haskell:

  • fast routing (both typesafe and "untyped")
  • middleware
  • json
  • sessions
  • cookies
  • database helper
  • csrf-protection


  • https://github.com/philopon/apiary-benchmark
  • https://github.com/agrafix/Spock-scotty-benchmark
{-# LANGUAGE OverloadedStrings #-}
import Web.Spock

import qualified Data.Text as T

main =
    runSpock 3000 $ spockT id $
    do get ("echo" <//> var) $ \something ->
        text $ T.concat ["Echo: ", something]

(read more at Type-safe routing in Spock)

Usage (Simple)

{-# LANGUAGE OverloadedStrings #-}
import Web.Spock.Simple

import qualified Data.Text as T

main =
    runSpock 3000 $ spockT id $
    do get ("echo" <//> ":something") $
        do Just something <- param "something"
           text $ T.concat ["Echo: ", something]
       get ("regex" <//> "{number:^[0-9]+$}") $
        do Just number <- param "number"
           text $ T.concat ["Just a number: ", number]


  • Using cabal: cabal install Spock
  • From Source: git clone https://github.com/agrafix/Spock.git && cd Spock && cabal install



The following Spock extensions exist:

Works well with Spock

Example Projects


Companies / Projects using Spock

  • http://cp-med.com/
  • http://openbrain.co.uk/
  • http://findmelike.com/
  • https://www.tramcloud.net
  • http://thitp.de


Since version Spock supports typesafe routing. If you wish to continue using the untyped version of Spock you can Use Web.Spock.Simple. The implementation of the routing is implemented in a separate haskell package called reroute.

Since version Spock is no longer built on top of scotty. The design and interface is still influenced by scotty, but the internal implementation differs from scotty's.

Thanks to

  • Tim Baumann Github (lot's of help with typesafe routing)
  • Tom Nielsen Github (much feedback and small improvements)