Conduit to yield first lines from file without leaking space or file handles?
Haskell Community [Unofficial]
May 2, 2026
danidiaz:
my own toy library jet-stream
Nice! Your Jet type is isomorphic to a special case of Bluefin streaming. Let’s see how.
We have
newtype Jet a = Jet
{ runJet :: forall s. (s -> Bool) -> (s -> a -> IO s) -> s -> IO s
}
which is
StateT s IO Bool -> (a -> StateT s IO ()) -> StateT s IO ()
(modulo the fact that the stop callback can’t modify the state). Now, I’m pretty sure that we could instead use
(a -> IO ()) -> IO ()
- The
StateT spart of this could be equivalently done by having anIORefin the closure of anIOhigher order function - Then the
stopcallback functionality could be handled by a useful combinatoruntil :: IO Bool -> Jet a -> Jet a
If I’m right then this is a special case of Bluefin streams which are implemented under the hood as (a -> IO ()) -> IO ().
I’m pretty sure what you call “continuation-based” streaming libraries are the right way to go.
Discussion in the ATmosphere