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
|
||||
-> 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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user