Code/style review

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Code/style review

Jan von Löwenstein
Hi,

TL;DR

Longer version:
I started looking into Haskell back in November last year. Pretty soon I wanted to try something more "real-world" IO heavy in order to see how that goes.
I came up with a side-project at work to implement a Bosh Kubernetes CPI. Bosh (bosh.io) is a tool to install and manage distributed systems on a range of IaaSs. In particular it is used to install Cloud Foundry (a cloud application development platform). I guess I don't have to introduce Kubernetes.

The interface between Bosh and its cloud provider interfaces (CPI) is a simple command line application. Bosh provides configuration via file provided as process call argument. It provides the method to be invoked including arguments as JSON via stdin and expects a response via stdout. The CPI can provide a log via stderr. (http://bosh.io/docs/cpi-api-v1.html)

The interface to Kubernetes is basically a REST api, i.e. http calls. Currently I use a generated client based on Servant (https://github.com/soundcloud/haskell-kubernetes)

I have put that interface into its own package. 
I created two typeclasses FileSystem[1] and System[2] to abstract away the system (I guess I should call them MonadFileSystem and MonadSystem to align with how mtl calls the monadic classes). And I created another typeclass MonadCpi[3] to abstract away the concrete implementation towards potentially several infrastructures.

The Kubernetes implementation[4] is rather hacked (no tests, low testability, etc.) and I'd like to change that. I thought about a typeclass for REST resources (with methods create, get, list, update, delete, ...) and I begin to have problems integrating that into my current primitives (e.g. I'd like to have a MonadLog instance that uses my System typeclass for printing to stderr). That's when I started to ask myself if I had chosen the right Haskell tools and primitives for what I was doing and thought it was time to get some feedback from more experienced Haskellers aka you.

I know this was a pretty long text. Sorry for that. Any feedback, including "you did it completely wrong" is appreciated - as long as it includes "have a look here and here", "look this is what I would do", or similar.

Many thanks already for reading.

Best
Jan


_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.