
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: https://github.com/softwarefactory-project/gerritbot-matrix/blob/71644a21a9a... -Tristan