yellowtides / owenbot-hs

A utility bot written in Haskell for the Edinburgh Informatics Class of ‘24’s main messaging platform (Discord server).
https://yellowtid.es/owenbot-hs/
BSD 3-Clause "New" or "Revised" License
8 stars 7 forks source link

Make Owen portable #30

Closed jacobjwalters closed 3 years ago

jacobjwalters commented 3 years ago

Currently, we assume a POSIX-compliant system in a few places. It'd be nice if we could support Windows also, as this would allow those who do not have WSL/access to a Unix system to help contribute.

We rely on POSIX features in:

Providing a generic getProcessID should be fairly simple. The idea is to add a new file that abstracts over OS differences using the CPP extension, which allows us to use the C Pre-Processor to conditionally import a library.

Replacing the chained call in update should be fairly simple, as I believe that System.Process provides methods to choose where to spawn a process.

Additionally, we depend on the following (Unix) utilities

Fixing the above would remove the sh and cd dependencies, but the others are hard dependencies of owen features, so short of reimplementing them in Haskell we're stuck with them.

Conditionally enabling these features by using #29 would perhaps be the most elegant way of handling this.

yutotakano commented 3 years ago

As it is expected Git and Stack would be installed if they are doing Haskell stuff on Windows (sorry pure cabal users), we should be fine with those two. cd is universal and works with the same syntax. && works as expected (it executes the second command only if the first was successful).

jacobjwalters commented 3 years ago

&& does rely on a POSIX-compliant shell though. That should be fairly easy to fix though (since the idiomatic way of doing so would be chaining Process.spawnCommand calls in an IO monad (there's a version of Process.spawnCommand that accepts a working directory IIRC)

jacobjwalters commented 3 years ago

This is almost very nearly complete, but the git repo is hardcoded to ~/owenbot.hs, meaning that :update won't work on Windows (and likewise, it won't be able to find the git info at startup).

In the future, this will get moved to a config file.

Since this is mostly for convenience with the production instance (which runs on Linux), it's not a big problem. Closing this issue.