[Haskell-cafe] Wrapping external process communication in a nice API?

Tristan Cacqueray tdecacqu at redhat.com
Mon May 31 13:03:43 UTC 2021

On Sat, May 29, 2021 at 16:59 Mario Lang wrote:
> Hi.
> 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.
> https://github.com/mlang/chessIO/blob/master/src/Game/Chess/UCI.hs

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...
Name: signature.asc
Type: application/pgp-signature
Size: 515 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20210531/2f84c516/attachment.sig>

More information about the Haskell-Cafe mailing list