The Haskell Chat Client

2017/04/25 code haskell

I've been working more on the backend for this little chat experiment.

At least the documentation is clear. Wai is great.

2017/03/26

My forays into doing something non-esoteric ("build you a Scheme?" eh) with Haskell are always stymied by issues with the ecosystem. Last time I tried it for Project Euler, getting a prime number generator was a pain in the ass. There's a misleading pretty one-liner that is in fact not a sieve, and then there's an insanely complex sieve with an entire research paper dedicated to it using wheels and other stuff. Bizarre.

This time, I wanted websockets, which Python struggles with, but Haskell handles very well. The issue had to do with my developing in OSX and wanting to run in Linux. I remarked earlier that, in spite of it being ugly and brutish code-wise, it was amazing how Go would easily statically compile a binary from OSX that I could just dump on my Ubuntu DO droplet, and it all would magically work. No need to procure extra resources for a build step on the server. I heard that Haskell was similarly powerful.

Long story short, cross-compilation is at best insanely hard to get going (no simple stack command will do the trick), and at worst it's a giant resource intensive procedure involving setting up VirtualBox and god knows what else, or using GitHub so that Halcyon can compile binaries for you, or other clunky involved systems.

I decided that the best solution in the end is to aim for relatively few releases, and have a little pipeline set up so that I can just spin up an Ubuntu DO droplet with a lot of RAM and CPU, compile binaries, pass them over to my actual server, and then destroy it. And it felt right, so this is how I'll be moving forward. All the client-side work can be iterated over quickly anyway without touching any of that stuff.

So, steps:

  1. Code in Haskell, test locally, have fun.
  2. When ready, go on DO website, spin up BUILD droplet.
  3. Install requirements (gcc, stack).
  4. Authorize local to push to BUILD, authorize BUILD to push to PRODUCTION.
  5. Push static files to PRODUCTION.
  6. Delete BUILD droplet.

It feels right. Or, at least, it feels better than using VirtualBox.