[web-devel] Type-safe URL handling

Jeremy Shaw jeremy at n-heptane.com
Tue Mar 16 17:00:25 EDT 2010


Hello,

I believe this is essentially how URLT works, except the 'toAbsPath'
function is stored in the reader monad instead of being passed around
manually.

And advantage of using the reader monad is that it also ensures that you are
dispatching the right type of URL in each part. More on this in a different
post later.

- jeremy

On Tue, Mar 16, 2010 at 3:49 PM, Michael Snoyman <michael at snoyman.com>wrote:

> 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.
>
> http://gist.github.com/334475
>
> 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.)
>
> Michael
>
> _______________________________________________
> web-devel mailing list
> web-devel at haskell.org
> http://www.haskell.org/mailman/listinfo/web-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/web-devel/attachments/20100316/e06bb271/attachment.html


More information about the web-devel mailing list