Skip to content

Instantly share code, notes, and snippets.

@codygman
Last active August 29, 2015 14:24
Show Gist options
  • Save codygman/d81e747cf7db1c849a23 to your computer and use it in GitHub Desktop.
Save codygman/d81e747cf7db1c849a23 to your computer and use it in GitHub Desktop.
0 to Haskell web development on Windows in 10 minutes
1. Download https://github.com/commercialhaskell/stack/releases/download/v0.1.2.0/stack-0.1.2.0-x86_64-windows.zip
2. Create the folder %APPDATA%\local\bin (e.g. "c:\Users\Michael\AppData\Roaming\local\bin") if it doesn't exist
3. Extract the zip file above there
4. Append the folder location where stack installs user applications on your path: C:\Users\%user%\AppData\Roaming\local\bin\ (e.g. "C:\Users\Michael\AppData\Roaming\local\bin")
5. WARNING: Be sure that the paths you added don't have any spaces or you'll run into problems.
7. Create a folder (e.g. C:\Users\Michael\my-spock-project) for your project
8. Open a cmd.exe and navigate (e.g. cd C:\Users\Michael\my-spock-project) to your projects folder
9. stack setup
10. stack new
11. Open new-template.cabal and find the section called library. Go to the section called build-depends and on the next line put ", Spock" without the quotes.
12. Save the following into app/Main.hs:
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.Monoid
import Web.Spock.Safe
main :: IO ()
main =
runSpock 8080 $ spockT id $
do get root $
text "Hello World!"
get ("hello" <//> var) $ \name ->
text ("Hello " <> name <> "!")
13. stack install
14. new-template-exe
15. Visit http://localhost:8080 in your browser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment