[Haskell-cafe] Code/style review
Jan von Löwenstein
jan.loewenstein at gmail.com
Fri Mar 24 20:57:03 UTC 2017
I am pretty new to Haskell and have some Haskell code I'd love to get
feedback on. (
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
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
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 (
I have put that interface into its own package.
I created two typeclasses FileSystem and System 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 to abstract away the concrete implementation towards
potentially several infrastructures.
The Kubernetes implementation 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
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe