I have had some experience with the Yesod framework and wanted to share my opinion on whether it's good or bad.
What is yesod?
Yesod is an MVC framework so think of Ruby on Rails or Django, written and used in Haskell, it's mostly split into three parts.
Controllers (Routing and Handlers)
Controllers is the part where you write the logic of the website like what routes you want to have and what to do when you receive a request, in Yesod this is split between two sections:
Routing
Routing is done via an embedded domain specific language utilizing Haskell's Template Haskell, it's easy and it's the best part about Yesod in my opinion, here is an example:
/software/#SoftwareId SoftwareR GET POSTThis adds a software route with an enumerated SoftwareId integer,
SoftwareR is the identifier to use for the route, GET and POST are
the HTTP methods allowed.
Handlers
Handlers are done in the Handler monad, to make a Handler, for example
to make a GET handler, you make a function name starting with get
like getHomeR = ... and likewise with POST.
View
The view is what the end user sees in a website, from all the fanciness of CSS to the dynamism of JS, it's all here.
Shakespearen templates
Shakespearean templates are what you would use to make the view, they are different from web DSLs by having:
- type guarantees
- Interopelation of Haskell data
- Indentation style rather than curly braces style.
Shakspearen templates also have an Emacs mode which is nice.
Widget
Widget is the monad where your shakespearen templates live in, the great
thing about Widget is that you can easily compose it, assume that you
have widgetHtml, widgetCSS, widgetJS, you can easily compose them like
widgetFull = widgetHtml + widgetCSS + widgetJS.
Model
The default database interface is Persistent (it comes with the DB oriented scaffold's), you can use SQLite, Postgresql and more.
Persistent
To make effects (use the DB), you can use use the entry point function
runDB, there was a large learning curve to make sure that the types
match but after you understand it, it's pretty smooth.
Pros && Cons
Pros
Modularity
Yesod is modular where you can choose DB's or template engines, it is also build on top of WAI which is/can also used by other libraries/frameworks like Servant and IHP.
Documentation
Yesod has a book that is easy to read and has great code examples though it is slightly terse in that i wish it has a bit more depth is some topics.
Cons
Modularity
Modularity is a pro and a con for Yesod, the problem is that since Yesod is so modular, the documentation takes a hit by not necessarily assuming that you are using the default scaffold.
Lack of community
This is my biggest problem with Yesod, it lacks a community around it therefore you have to ask in haskell channels which may or may not provide the help wanted.
Persistent
Persistent lacks composability badly, there are most likely reasons for this but it still a complaint in my opinion
Bootstrap version
In the scaffolding, Yesod still uses Bootstrap 3, rather than Bootstrap 4 or even 5, which makes finding documentation a little unpleasant.
Language extensions
Yesod uses language extensions, some of which are:
Template Haskell
I like the use of template haskell as a way to make DSL's for routing and compsobale widgets, the error messages though generally are horrible are extremely confusing.
Typefamilies
As Yesod is a beginner web framework, it shouldn't deal with type-level programming but alas it does with functions from types to types.
Refresh
Yesod doesn't automatically refresh the browser, in 2023 this is a necessary feature and makes the developer experience much much better.