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
Benchmarks:
{-# 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]
{-# LANGUAGE OverloadedStrings #-}
import Web.Spock.Safe
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)
- Using cabal:
cabal install Spock
- From Source:
git clone https://github.com/agrafix/Spock.git && cd Spock && cabal install
The following Spock extensions exist:
- Background workers for Spock: Spock-worker
- Digestive functors for Spock: Spock-digestive
- User management users
- Data validation validate-input
- Blaze bootstrap helpers blaze-bootstrap
- digestive-forms bootstrap helpers digestive-bootstrap
- German: Moderne typsichere Web-Entwicklung mit Haskell (by Alexander Thiemann)
- German: reroute-talk (by Tim Baumann)
- http://cp-med.com/
- http://openbrain.co.uk/
- http://findmelike.com/
- https://www.tramcloud.net
- http://thitp.de
Since version 0.7.0.0 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 0.5.0.0 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.