Skip to content

Instantly share code, notes, and snippets.

@kephas
Created August 20, 2025 00:22
Show Gist options
  • Save kephas/bc2587ea2976a3ce46efaec4568c5668 to your computer and use it in GitHub Desktop.
Save kephas/bc2587ea2976a3ce46efaec4568c5668 to your computer and use it in GitHub Desktop.
Connect-and-resume a conduit
import Conduit
import Data.Char (toUpper)
upcaseUntil :: (Monad m) => Char -> ConduitT Char Void m String
upcaseUntil breaker = takeWhileC (/= breaker) .| mapC toUpper .| sinkList
resumeAfter :: (Monad m) => ConduitT () Char m () -> ConduitT Char Void m String -> ConduitT () Char m ()
resumeAfter source process = do
(next, begin) <- lift $ source $$+ process
yieldMany begin
unsealConduitT next
main :: IO ()
main = do
putStrLn $
runConduitPure $
yieldMany "foo:bar" `resumeAfter` upcaseUntil ':' .| sinkList
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment