Created
October 29, 2021 14:40
-
-
Save adamConnerSax/f115bb26a15e597d1199d42af2645568 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unfoldViaBS' :: Applicative m => Streamly.Unfold.Unfold m BL.ByteString BL.ByteString | |
unfoldViaBS' = Streamly.Unfold.unfoldr inner | |
where | |
{-# INLINE inner #-} | |
inner input' | |
| BL.null input' = Nothing | |
| otherwise = | |
case BL.elemIndex _lf input' of | |
Nothing -> Just (input', BL.empty) | |
Just i -> | |
let (prefix, suffix) = BL.splitAt i input' | |
in Just (prefix, BL.drop 1 suffix) | |
{-# INLINE unfoldViaBS' #-} | |
unfoldViaBS :: MonadIO m => Streamly.Unfold.Unfold m IO.Handle Text | |
unfoldViaBS = fmap (Text.decodeUtf8 . BL.toStrict) $ Streamly.Unfold.lmapM (liftIO . BL.hGetContents) unfoldViaBS' | |
{-# INLINE unfoldViaBS #-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment