I would like to input and to output octets, via IO (), as is, and without any encoding, respectively. The octets have type [Word8]. The stream shall be stdin, stdout, stderr, and files.
Background: I am going to implement a declarative compiler. This parser should be capable to interpret octet by octet, and render octet by octet.
import qualified Octetable as Oct import qualified Data.Word as W import qualified System.IO as SysIo main :: IO () main = do putOctets SysIo.stdout octets putOctets :: SysIo.Handle -> [W.Word8] -> IO () putOctets hOut octs = do SysIo.hPutBuf hOut ??? octs (length octs) octets :: [W.Word8] octets = Oct.toOctets "Hallo!" How to do implement putOctets to do that?
...and getOctets?
getOctets :: SysIo.Handle -> IO [W.Word8] getOctets hOut = ... I will investigate further, and publish. Hopefully, someone will be faster. I already search for days.
https://stackoverflow.com/questions/67131798/how-to-do-io-without-encoding-in-haskell April 17, 2021 at 04:26AM
没有评论:
发表评论