Skip to content

Instantly share code, notes, and snippets.

@kephas
Created August 20, 2025 00:22
Show Gist options
  • Select an option

  • Save kephas/bc2587ea2976a3ce46efaec4568c5668 to your computer and use it in GitHub Desktop.

Select an option

Save kephas/bc2587ea2976a3ce46efaec4568c5668 to your computer and use it in GitHub Desktop.

Revisions

  1. kephas created this gist Aug 20, 2025.
    17 changes: 17 additions & 0 deletions upcaseUntil.hs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    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