Skip to content

Instantly share code, notes, and snippets.

@epicallan
Created August 11, 2019 13:59
Show Gist options
  • Save epicallan/fbcf8134df784d31bee85367de46e856 to your computer and use it in GitHub Desktop.
Save epicallan/fbcf8134df784d31bee85367de46e856 to your computer and use it in GitHub Desktop.
-- | example of monadic effectful code that can throw multiple errors
simpleHttp
:: forall m . (ThrowsMany m '[ HTTPException, DBException ], HttpNetwork m User)
=> Id -> m User
simpleHttp userId = do
user <- getHttp userId
case uId user of
x | x == userId -> pure user
| x == "Null" -> throwChecked DBException
| otherwise -> throwChecked HTTPException
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment