aboutsummaryrefslogtreecommitdiff
path: root/src/ImageHoster
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2020-03-03 14:50:18 +0100
committerDaniel Schadt <kingdread@gmx.de>2020-03-03 14:50:18 +0100
commita440dcbb89f74b607720bb5805390749861f9fe5 (patch)
treed44516815a8a801f377ef0d6b870a27ec11510bd /src/ImageHoster
parent74b373d23d35446d772d6bb2b01c49ca38978236 (diff)
downloadsimghost-a440dcbb89f74b607720bb5805390749861f9fe5.tar.gz
simghost-a440dcbb89f74b607720bb5805390749861f9fe5.tar.bz2
simghost-a440dcbb89f74b607720bb5805390749861f9fe5.zip
rewrite handleUpload
This way we avoid the right-drift that we introduced in the first version, as the error handling and propagation is done in the Maybe monad. The downside to this is that we lose some error information: We cannot show anymore if the authorization failed or something else went wrong, because in all cases we just bail out with Nothing.
Diffstat (limited to 'src/ImageHoster')
-rw-r--r--src/ImageHoster/Monad.hs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/ImageHoster/Monad.hs b/src/ImageHoster/Monad.hs
index a05d59d..198ebd5 100644
--- a/src/ImageHoster/Monad.hs
+++ b/src/ImageHoster/Monad.hs
@@ -7,6 +7,7 @@ module ImageHoster.Monad
, FallibleApp
-- * Conversion functions
, runFallibleApp
+ , fallible
, liftApp
, run
-- * Data accessors
@@ -54,6 +55,11 @@ runFallibleApp :: FallibleApp a -> App (Maybe a)
runFallibleApp = runMaybeT
+-- | Ensure that a computation that can fail runs as a 'FallibleApp'.
+fallible :: App (Maybe a) -> FallibleApp a
+fallible = MaybeT
+
+
-- | Lift an 'App' to a 'FallibleApp' that never fails.
liftApp :: App a -> FallibleApp a
liftApp a = MaybeT $ Just <$> a