3 ms·
The article only seems to concern handling effectful input. But i can't really imagine what the type for writing to stdout would look like. Would it be someth
by arianvanp 5y ago
The article only seems to concern handling effectful input. But i can't really imagine what the type for writing to stdout would look like.
Would it be something simple as:
writeStdout :: ByteStream IO a -> IO a
?
- wyager 5y agoSure, that could work, or something like mapM_ :: (ByteString -> m a) -> ByteStream m b -> m b And then you just have writeStreamToStdout = mapM_ writeBytesToStdout
- WJW 5y agoMaybe I misunderstand what you mean, but why not just: writeStdout :: ByteStream a -> IO () Maybe you could even leave out the `a` type since arguably a `ByteStream` should only contain bytes anyway. When writing to stdout you don't really need a return value usually, so that could just be (). The IO monad can encapsulate any amount of side effects in the same function, so you could fit your additional side effects in besides writing to stdout.