More polymorphism.
This commit is contained in:
parent
0f0f77344f
commit
4191d65fc5
@ -47,11 +47,14 @@ instance Default Zip.ZipInfo where
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
consumeZip :: (ZipEntry -> YesodDB UniWorX a) -- ^ Insert entries into database
|
consumeZip :: ( MonadBase b m
|
||||||
-> Sink ByteString (YesodDB UniWorX) (Zip.ZipInfo, [a])
|
, PrimMonad b
|
||||||
consumeZip insertEntry = Zip.unZipStream `fuseBoth` consumeZip'
|
, MonadThrow m
|
||||||
|
) => (ZipEntry -> m a) -- ^ Handle entries (insert into database)
|
||||||
|
-> Sink ByteString m (Zip.ZipInfo, [a])
|
||||||
|
consumeZip handleEntry = Zip.unZipStream `fuseBoth` consumeZip'
|
||||||
where
|
where
|
||||||
-- consumeZip' :: Sink (Either Zip.ZipEntry ByteString) (YesodDB UniWorX) [a]
|
-- consumeZip' :: Sink (Either Zip.ZipEntry ByteString) m [a]
|
||||||
consumeZip' = do
|
consumeZip' = do
|
||||||
input <- await
|
input <- await
|
||||||
case input of
|
case input of
|
||||||
@ -66,7 +69,7 @@ consumeZip insertEntry = Zip.unZipStream `fuseBoth` consumeZip'
|
|||||||
zipEntryContents
|
zipEntryContents
|
||||||
| hasTrailingPathSeparator zipEntryName = Nothing
|
| hasTrailingPathSeparator zipEntryName = Nothing
|
||||||
| otherwise = Just $ Lazy.ByteString.fromChunks contentChunks
|
| otherwise = Just $ Lazy.ByteString.fromChunks contentChunks
|
||||||
(:) <$> (lift $ insertEntry ZipEntry{..}) <*> consumeZip'
|
(:) <$> (lift $ handleEntry ZipEntry{..}) <*> consumeZip'
|
||||||
accContents :: Monad m => Sink (Either a b) m [b]
|
accContents :: Monad m => Sink (Either a b) m [b]
|
||||||
accContents = do
|
accContents = do
|
||||||
input <- await
|
input <- await
|
||||||
|
|||||||
Reference in New Issue
Block a user