4
votes

I've been having a crack at using Yesod and I'm really struggling! I've read multiple tutorials and large amounts of the Yesod book but I'm still unable to get my head around how it works. Ideally I'm looking for a tutorial such as the one for Pyramid (a python web framework). It takes you through every step and explains everything very well.

Sadly I've not been able to find a similar style of tutorial for Yesod yet. If anybody knows of one I'd be delighted if you could furnish me with a link.

In the meantime I've some a more specific query.

I've created a site using the scaffold as suggested in the tutorials. If I want to add new Handlers, Models and Templates, do I need to add individual files into each of the relevant folders each time or can I organise them into their own sub-folders somehow? When I use Pyramid I'm able to put each module in its own folder.

1
Did you go through this excellent book available online ? Do you have prior haskell experience ? - Sibi
I've been looking at the book online (I even have a paper copy!) and several of my google searches have taken me to it too. However I can't find anything that seems to explain how file organisation should work or anything that'll walk me through an entire site. I've read LYAH and so have some Haskell experience but I'm certainly still a beginner. - Teifion
I wouldn't use the scaffolding initially if I were you. I think you're best to start by messing with sites which are defined in a single file, like the Bartosz Milewskis tutorials on the School of Haskell. Note there are a lot of other useful tutorials and articles on this site. I've written quite a lot of stuff with Yesod (admittedly not very visual, so not a lot of templates), and I still haven't used the scaffolded layout. - Shaun the Sheep

1 Answers

3
votes

Michael Snoyman has written an excellent book which covers every major aspect of web development with Yesod. For more specific tutorials, try taking a look at FP Complete which has extensive material on Yesod. I found this tutorial in particular to be very useful. (Both of these assume a reasonably advanced knowledge of Haskell itself. If this is something you lack, I strongly recommend reading "Learn You a Haskell for Great Good!")

As for adding handler to the scaffolded site, there is actually a builtin command for just that purpose. Running yesod add-handler will ask you for all of the necessary information for creating a skeleton handler (handler name, path, POST or GET, etc.) and will create/modify all of the necessary files for you. Then you just have to add the logic itself to "Handler/MyHandler.hs".