Rotaerk 2017-01-28 18:45:12
look through this https://hackage.haskell.org/packages/search?terms=pipes
Rotaerk 2017-01-28 18:45:32
maybe pipes-bytestring or pipes-binary
xpika 2017-01-28 18:47:25
Rotaerk: thanks
Wizek 2017-01-28 18:48:04
glguy, I'm back and I figured it out! Thanks for the pointers. The type became `hmAt :: _ => k -> Lens' (HM.Map k v) (Maybe v)` and `s` became `s m v = HM.alter (const v) k m`
dmwit_ 2017-01-28 18:48:11
xpika: pipes appears to just use System.IO under the hood.
dmwit_ 2017-01-28 18:48:31
xpika: So I suspect you should be able to just call `hSetBuffering NoBuffering` and the one of the `take`-alikes.
Rotaerk 2017-01-28 18:48:58
ah, does hSetBuffering do what I was talking about?
kadoban 2017-01-28 18:49:22
I can't tell if this is actually a buffering question. Do you actually want to turn off buffering, or do you only need to make sure that an infinitely long line doesn't break things?
Rotaerk 2017-01-28 18:49:47
neat, it does
dmwit 2017-01-28 18:49:53
I mean, of course there's also BlockBuffering if you still want the benefits of buffering.
EvanR 2017-01-28 18:50:04
seems like they want to react to invidual bytes available on stdin
dmwit 2017-01-28 18:50:21
EvanR: That isn't clear to me, although that's the specific question they asked.
EvanR 2017-01-28 18:50:47
... right... *presses the "what are you really trying to do" button*
Rotaerk 2017-01-28 18:50:54
given that they weren't sure whether it would fill memory, it seemed unlikely to be a user entering input as opposed to a file being piped into their program or something
Wizek 2017-01-28 18:50:58
glguy, also, for some reason I was very irked by `s` having to take a Maybe value. Seemed like a useless wrapper, since in my case I always wanted to set Just a value. Until I realized that Nothing encodes deletion. Which makes tremendous sense, even if I may not use in this usecase.
Rotaerk 2017-01-28 18:51:19
and said file may have huge lines
Rotaerk 2017-01-28 18:51:29
just guessing though...
glguy 2017-01-28 18:53:15
Wizek: Nice work!
dmwit 2017-01-28 18:53:31
xpika: Something like `charFromHandle h = liftIO (hSetBuffering h BlockBuffering) >> go where go = do { eof <- liftIO $ IO.hIsEOF h; unless eof (liftIO (hGetChar h) >>= yield >> go) }`.
dmwit 2017-01-28 18:53:46
xpika: (Cribbing from the implementation of `Pipes.Prelude.fromHandle`, which is line-based.)
dmwit 2017-01-28 18:55:43
oops
pikajude 2017-01-28 18:56:02
heh, ex-pika
dmwit 2017-01-28 18:56:13
should be `(BlockBuffering (Just 1024))` or whatever size buffer you're comfortable with. `Nothing` means you don't care
dmwit 2017-01-28 18:56:43
Never knew about `hShow`. That looks fun.
user__ 2017-01-28 19:18:16
testing