[Haskell-cafe] Wrapping external process communication in a nice API?
tdecacqu at redhat.com
Mon May 31 13:03:43 UTC 2021
On Sat, May 29, 2021 at 16:59 Mario Lang wrote:
> For my chessIO package, I wrote a module to communicate with
> UCI (Universal Chess Interface) speaking chess engines.
> This sort of thing is pretty new to me.
> I settled to use attoparsec for parsing and
> TChan to feed incoming data to the library users.
> This is the first thing that I found which looked like it could work...
> I would be thrilled if someone with more experience in this area would
> give my approach a review. Let me know if something is glaringly
> unidiomatic, I am sure you will find things.
It seems like it would be safer to use withCreateProcess instead of
createProcess to ensure the process is not left unattended.
> This is for me to learn, and to avoid putting weird stuff on hackage...
> I actually prefer private mail, but a GitHub issue or even a PR are also
> highly welcome.
I had the same need for a matrix bot where the events come from a ssh
process stream. There is `streaming-commons` and `conduit-extra`, but I
am not familiar enough with conduit to make it work.
In the end I used `turtle` to callback with each line output.
For what it worths, here is my current implementation:
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 515 bytes
Desc: not available
More information about the Haskell-Cafe