[Haskell-beginners] Design of Webmachine in Haskell

Petar Radosevic petar at wunki.org
Sat Apr 14 18:38:06 CEST 2012


Hi,

I would love to create a port of Webmachine [1] in Haskell so I can
learn the language and in the meanwhile create something useful. The
problem is, I don't know how I would design such a system in Haskell.

Simply put, webmachine is a library in Erlang which let's you create a
REST API by binding resources to URI's. The resources have sane
defaults, defined with functions, like `resource_exists`,
`service_available` and `is_authorized`. You can override these
functions per resource to create your own API. Webmachine will then
create the appropriate response when a request comes in.

I have been thinking how to implement such a system in Haskell, and I
have come up with the following. First of, use WAI with Warp to handle
the `Request` -> `Response` cycle. That was easy to come up with, but
I'm still struggling with the following question: What would a
`Resource` be in Haskell? I need something that lets me define sane
defaults which I can override per resource. Should I have a `Resource`
typeclass which defines all the default functions? Or is there a better
way to accomplish this?

I hope the above was a bit clear, would appreciate any insights!

[1]: http://wiki.basho.com/Webmachine-Resource.html
-- 
Petar Radosevic | @wunki



More information about the Beginners mailing list