From 5df1fb660c0cb3a41e18e21802e482e7ea75fb7a Mon Sep 17 00:00:00 2001 From: Christopher Vollick <0@psycoti.ca> Date: Fri, 8 Jan 2021 12:01:38 -0500 Subject: [PATCH] Replace Non-Exhaustive Pattern with Case I did this because in newer versions of GHC things like this require a MonadFail instance, whereas explicitly handling it like this does not. Now, we don't currently require those newer versions, but since I happened to have a new one it was causing me trouble. And this new way works in both versions, so I think it's safe to just throw it in here. --- StoreChunks.hs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/StoreChunks.hs b/StoreChunks.hs index e395c1c..359feb1 100644 --- a/StoreChunks.hs +++ b/StoreChunks.hs @@ -34,11 +34,12 @@ storeChunks storePath tmpName getChunk = loop hashInit hashInit hashInit tmpPath = storePath ++ "/tmp/" ++ tmpName cidPath digest = storePath ++ "/" ++ textToString (digestCID digest) loop sha1 sha256 sha512 = do - Just chunk <- UIO.lift getChunk - if ByteString.null chunk then - finish sha1 sha256 sha512 - else - step sha1 sha256 sha512 chunk + maybeChunk <- UIO.lift getChunk + case maybeChunk of + Nothing -> return $ Left $ userError "Failed to getChunk" + Just chunk + | ByteString.null chunk -> finish sha1 sha256 sha512 + | otherwise -> step sha1 sha256 sha512 chunk step sha1 sha256 sha512 chunk = do result <- UIO.fromIO' (error.show) $ do -- 2.34.2