Yesod excellent ideas
Yesod is a framework which has recently matured to the point where you should consider using it. Before telling you why you should learn Haskell and use Yesod, I will illustrate the many features Yesod introduces which are missing in other frameworks.
Let’s start by an obligatory link from xkcd:
Newton<script>alert("An apple fall")</script>
You must transform each
Yesod does its best to handle cross scripting issues. Both between the client and the server and between the server and your DB. Here is an example:
<a href=@[AnotherPageR]>Go to another page
AnotherPageR is of type URL and it could not contains something nefarious. It will be an URL safe. Not something like:
falselink"><script> bad_code(); </script><a href="pipo
- the footer of a webpage,
- the header of a webpage with a menu,
- a button which appears only when scrolling down,
For each of this part, you might need,
- a bit of HTML,
- a bit of CSS and
Some in the header, some in the body.
You can declare a widget as this (note I use a very high meta-language):
The real syntax is:
toWidgetHeader cassiusFile "button.cassius" toWidgetHeader juliusFile "button.julius" toWidget hamletFile "buttonTemplate.hamlet"
Note the awesome Shakespearean inspired name convention. Another good reason to use yesod.
- Cassius & Lucius of CSS (a lot similar to SASS and SCSS),
- Hamlet for HTML (similar to haml)
And when your page render, yesod makes it easy to render everything nicely:
myBigWidget = menuWidget >> contentWidget >> footerWidget
Furthermore, if you use say 10 widgets each with a bit of CSS, yesod will create a unique and compressed CSS file. Except if you expressed a need to change the header by using different CSS.
This is just awesome!
In standard routing system you have for each entry a couple: regexp → handler
The only way to discover the right rules is to match each regexp to the current URL. Then you can see behaviour such as, if you change the order of the rules you can lose or win time.
On the other hand yesod compiles the routes. Therefore it can optimize it. Of course two routes must not interfere.
/blog/2003 Date2003R /blog/$DATE DateR
is invalid by default (you can make it valid, but I don’t think it is a good idea).
and test if
date = 2003 inside the handler.
- Speed. This is just astounding. Look at this and then to this.
- Haskell. This is certainly hard to learn but also incredibly awesome. If you want to make you a favor. Just learn Haskell. It will be difficult, far more than you can imagine. It is very different from all other languages I used. But it will blow your mind and learn you a bunch of new programming concepts.
- Good ideas, excellent community. I follow yesod from some month now and the speed at which the project progress is incredible.
If you are a haskeller, I believe you shouldn’t fear the special syntax imposed by the standard yesod way of doing things. Just try it more than the firsts basic tutorials.
To conclude, Yesod is awesome. Just overcome the difficulties about learning a bit of haskell and try it!