[web-devel] Type-safe URL handling

Michael Snoyman michael at snoyman.com
Tue Mar 16 16:49:01 EDT 2010

Here's a bit of an orthogonal gist to what Chris has posted. It's very
tedious to program in this style, but it could form the basis for other
libraries to build on top of it.


WebPlug is a typeclass that consists of three methods: one to convert to a
relative path, one to convert from a relative path, and a dispatch method.
The trick is that dispatch is given a function that can convert a WebPlug
into an *absolute* path.

Given something like this, I could write a blog WebPlug that creates all
internal links via the absolute path function. They would all be guaranteed
to be valid by definition, and then the blog could be plugged into another
application at any point.

Some standards for loading settings and the like *might* be nice, but aren't
really necesary. Also, I believe that this approach is compatible with
either the regular package approach Chris uses above, or a quasi-quoting
approach like in Yesod. (Obviously the Yesod code itself would have to
change to accomodate this.)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/web-devel/attachments/20100316/72609f05/attachment-0001.html

More information about the web-devel mailing list