Two Wrongs

(don't make a right)

My Experience Using Yesod for a "Quick Hack"

by ~kqr

This is a post I've had brewing for a long time but I don't quite know what to write so I'll just throw it out there with the notes I had collected at the time.

I recently had reason to create a simple CRUD web thing. I wanted only very minimal functionality and I didn't want to spend time on it. I decided to try to use Yesod for this purpose. It might sound like the type of thing Haskell is not good for, because often with these things, it's more important to have a buggy site up quickly rather than something correct. So it was sort of a gamble.

However, it did turn out well after all. It's easy to set up CRUD scaffolding with Postgres using the Yesod CLI. It generates a lot of code, but most of it can be ignored, fortunately. The following files are the ones I'd consider important:

    - favicon.ico
    - models
    - robots.txt
    - routes
    - settings.yml
    - handlers for all routes
    - static content
    - hamlet, julius & cassius 

I don't generally want to create my own authentication protocols, and instead I prefer going through some OpenID provider who I trust a hell of a lot more with crypto data than myself. It was a little tricky to get this working, but I realised eventually the authenticate method was what I was looking for. After that, the scaffolding takes care of the rest already!

On an unrelated note: hamlet, the HTML templating language, is so good. It is one of the nicest things I've ever used, comparatively speaking. There are few things that fit so perfectly with their domain.

If you enjoyed this article, you might like others tagged with