Skip to content

Instantly share code, notes, and snippets.

@fghibellini
Created November 3, 2018 14:15
Show Gist options
  • Save fghibellini/230d416286d8f0b788cacb4e6959847b to your computer and use it in GitHub Desktop.
Save fghibellini/230d416286d8f0b788cacb4e6959847b to your computer and use it in GitHub Desktop.
Servant + postgresql-simple transactions (Handler vs. IO problem)
handler1 :: String -> Handler c
handler1 emailToken = liftIO $ withTransaction conn $ do
res1 <- findEmailTokenInDB emailToken :: IO a
if !foundToken(res1)
then (throwError $ err401) -- not an IO operation
else (do
deleteToken emailToken :: IO b
authenticateUser :: IO c
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment