Last active
August 29, 2015 14:04
-
-
Save co-dan/114894a726fd9aa19f13 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cabal install | |
Resolving dependencies... | |
Configuring haskellfun-0.0.1... | |
Building haskellfun-0.0.1... | |
Preprocessing executable 'haskellfun' for haskellfun-0.0.1... | |
[2 of 3] Compiling Controllers.Home ( Controllers/Home.hs, dist/dist-sandbox-ef4979d3/build/haskellfun/haskellfun-tmp/Controllers/Home.o ) | |
Controllers/Home.hs:15:16: | |
Couldn't match expected type `Database.RethinkDB.NoClash.RethinkDBHandle' | |
with actual type `IO Database.RethinkDB.NoClash.RethinkDBHandle' | |
In the first argument of Database.RethinkDB.NoClash.run', namely | |
`conn' | |
In the expression: Database.RethinkDB.NoClash.run' conn | |
In the expression: | |
Database.RethinkDB.NoClash.run' conn | |
$ Database.RethinkDB.NoClash.dbCreate "haskellfun" | |
Controllers/Home.hs:16:16: | |
Couldn't match expected type `Database.RethinkDB.NoClash.RethinkDBHandle' | |
with actual type `IO Database.RethinkDB.NoClash.RethinkDBHandle' | |
In the first argument of `Database.RethinkDB.NoClash.run', namely | |
`conn' | |
In the expression: Database.RethinkDB.NoClash.run conn | |
In the expression: | |
Database.RethinkDB.NoClash.run conn | |
$ Database.RethinkDB.NoClash.dbList :: | |
IO (Maybe [String]) | |
Failed to install haskellfun-0.0.1 | |
cabal: Error: some packages failed to install: | |
haskellfun-0.0.1 failed during the building phase. The exception was: | |
ExitFailure 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
module Controllers.Home (homeRoutes) where | |
import Web.Scotty | |
import Data.Monoid (mconcat) | |
import qualified Database.RethinkDB as R | |
import qualified Database.RethinkDB.NoClash | |
homeRoutes :: ScottyM () | |
homeRoutes = do | |
conn <- liftIO $ R.connect "localhost" 28015 Nothing | |
setDb <- liftIO $ R.run' conn $ R.dbCreate "haskellfun" | |
getDbs <- liftIO $ R.run conn $ R.dbList | |
get "/" $ do | |
dbs <- getDbs | |
html $ mconcat ["<form action='/' method='post'><input type='text' name='name'></input><input type='submit'></input></form>"] | |
post "/" $ do | |
name <- param "name" | |
redirect $ mconcat ["/home/", name] | |
get "/home/:word" $ do | |
beam <- param "word" | |
html $ mconcat ["<h1>Scotty, ", beam, " me up home!</h1>"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
import Web.Scotty | |
import Data.Monoid (mconcat) | |
import Network.Wai.Middleware.RequestLogger (logStdoutDev) | |
-- Controllers | |
import Controllers.Home (homeRoutes) | |
main = scotty 3000 $ do | |
middleware logStdoutDev | |
homeRoutes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment