Description
@zarthross continuing our discussion from circe/circe#1855 (comment)
To bikeshed a bit, i was just imaging something of the signature
def printToStream[F[_]](json: Json, cs: Charset): Stream[F, Byte]
but we could go and do something likedef printPipe[F[_]](cs: Charset): Pipe[F, Json, Byte]
as well.For your use case in Feral you would be able to then do
printToStream(json).through(fs2.io.writeOutputStream(channel))
or something.Reason I suggest a different printer implementation is I think having an FS2 native implementation would be able to suspend the encoding of the json better, and just overall work better with FS2 than trying to hack around
Appendable
I agree that would certainly be a feature worth having. But unfortunately it doesn't address my use case. The problem with a printToStream(json).through(fs2.io.writeOutputStream(channel))
is that instead of printing the Json
directly to the output stream, it goes through an intermediate representation of Chunk[Byte]
which is exactly what I'm trying to avoid :)