From 4191d65fc51b763730a1adfade1f327996ce6115 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 5 Oct 2017 14:13:51 +0200 Subject: [PATCH] More polymorphism. --- src/Handler/Zip.hs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Handler/Zip.hs b/src/Handler/Zip.hs index fe1432c2d..a75c84c9b 100644 --- a/src/Handler/Zip.hs +++ b/src/Handler/Zip.hs @@ -47,11 +47,14 @@ instance Default Zip.ZipInfo where } -consumeZip :: (ZipEntry -> YesodDB UniWorX a) -- ^ Insert entries into database - -> Sink ByteString (YesodDB UniWorX) (Zip.ZipInfo, [a]) -consumeZip insertEntry = Zip.unZipStream `fuseBoth` consumeZip' +consumeZip :: ( MonadBase b m + , PrimMonad b + , MonadThrow m + ) => (ZipEntry -> m a) -- ^ Handle entries (insert into database) + -> Sink ByteString m (Zip.ZipInfo, [a]) +consumeZip handleEntry = Zip.unZipStream `fuseBoth` consumeZip' where - -- consumeZip' :: Sink (Either Zip.ZipEntry ByteString) (YesodDB UniWorX) [a] + -- consumeZip' :: Sink (Either Zip.ZipEntry ByteString) m [a] consumeZip' = do input <- await case input of @@ -66,7 +69,7 @@ consumeZip insertEntry = Zip.unZipStream `fuseBoth` consumeZip' zipEntryContents | hasTrailingPathSeparator zipEntryName = Nothing | otherwise = Just $ Lazy.ByteString.fromChunks contentChunks - (:) <$> (lift $ insertEntry ZipEntry{..}) <*> consumeZip' + (:) <$> (lift $ handleEntry ZipEntry{..}) <*> consumeZip' accContents :: Monad m => Sink (Either a b) m [b] accContents = do input <- await