[Haskell-beginners] Design of Webmachine in Haskell

Michael Snoyman michael at snoyman.com
Sun Apr 15 05:10:07 CEST 2012

On Sat, Apr 14, 2012 at 7:38 PM, Petar Radosevic <petar at wunki.org> wrote:
> 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
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners

Hi Petar,

When I was at QCon, I heard a talk from Steve Vinoski on Webmachine,
and I was surprised to hear how close webmachine was to Haskell
already, The concept is basically sticking a state monad on top of
WAI. My guess is you would want to use a record type for a Resource,
not a typeclass, to make it easier to swap out behaviors. But
honestly, I haven't given this any thought since I saw the
presentation 6 months ago.


More information about the Beginners mailing list