Skip to content

Instantly share code, notes, and snippets.

@shegeley
Last active September 2, 2019 14:46
Show Gist options
  • Save shegeley/7822ba994e9a4468b9a36bd4def5aef7 to your computer and use it in GitHub Desktop.
Save shegeley/7822ba994e9a4468b9a36bd4def5aef7 to your computer and use it in GitHub Desktop.
Explanation of my problem with scotty server
getProducts :: IO [Product]
main :: IO ()
main = do
S.scotty 3000 $ do
S.liftAndCatchIO getProducts >>= \products -> do
S.get "/" $ do ...
S.get "/products" $ do ...
{-|
• In a stmt of a 'do' block:
S.liftAndCatchIO getProducts
>>=
\ products
-> do S.get "/" $ do ...
S.get "/products" $ do ...
....
In the second argument of ‘($)’, namely
‘do S.liftAndCatchIO getProducts >>= \ products -> do ...’
In a stmt of a 'do' block:
S.scotty 3000
$ do S.liftAndCatchIO getProducts >>= \ products -> do ...
|
30 | S.liftAndCatchIO getProducts >>= \products -> do
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
/home/altjsus/Projects/cvetlandy-haskell/app/Main.hs:31:7: error:
• Couldn't match type ‘Web.Scotty.Internal.Types.ScottyT L.Text IO’
with ‘Web.Scotty.Internal.Types.ActionT L.Text IO’
Expected type: Web.Scotty.Internal.Types.ActionT L.Text IO ()
Actual type: S.ScottyM ()
• In a stmt of a 'do' block:
S.get "/" $ do S.html . renderHtml $ mainPage
In the expression:
do S.get "/" $ do ...
S.get "/products" $ do ..
S.get "/product/:id"
$ do ...
In the second argument of ‘(>>=)’, namely
‘\ products
-> do S.get "/" $ do ...
S.get "/products" $ do ...
....’
|
31 | S.get "/" $ do
| ^^^^^^^^^^^^^^...
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment