Skip to content

Instantly share code, notes, and snippets.

@tylerjl
Created February 3, 2021 03:20
Show Gist options
  • Save tylerjl/4532439a116ed694e68a61104e45ff02 to your computer and use it in GitHub Desktop.
Save tylerjl/4532439a116ed694e68a61104e45ff02 to your computer and use it in GitHub Desktop.
Experimenting with pluck
couldFail :: (MonadHttp m, OneOf err '[A, B]) => ExceptT err m [Key SomeEntity]
handleStuff :: Handler ()
handleStuff = do
result <- runExceptT $ do
action <- catchOneT (catchOneT couldFail
\(A _) -> $(logWarn) "Handling an A failure" >> pure mempty)
\(B _) -> $(logWarn) "Handling a B failure" >> pure mempty
return action
case result of
Left _noMoreErrsHereIGuess -> do
setMessage $ text $ "There were failures"
redirect HomeR
Right _thisCouldBeEmptyBecauesFailure -> do
redirect HomeR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment