Gabriella439 / pipes

Compositional pipelines
BSD 3-Clause "New" or "Revised" License
487 stars 72 forks source link

toHandle should not insert a newline automatically #219

Closed andrewufrank closed 4 years ago

andrewufrank commented 4 years ago

Today I was caught by the silent insertion of newline using toHandle. I found the previous discussion which suggested to rename toHandle to hPutStrLn. I would be happy with a toHandle and a toHandleLn.

I found by painful experience that functions should do only one thing and not for convenience add other functions. The additional functionality is typically causing enormous cost in those cases where the "convenience" is not wanted; usually searching for the explanation of an error. IMHO toHandle should just write to the handle whatever is there without adding anything.

Thank you for Pipe! It is an excellent demonstration of how powerful Haskell is.

Gabriella439 commented 4 years ago

@andrewufrank: The main reason that toHandle is line-based is for symmetry with fromHandle (which is also line-based)

What about adding two new utilities named putHandle and putHandleLn with a note in the documentation that toHandle is a synonym for putHandleLn?

andrewufrank commented 4 years ago

good solution - thank you! I will wait to see it in the next release. (I tried to make a putHandle myself, but it did not work; likely I was distracted by the application issue I wanted to solve. )