Yesod sample projects - haskell

I am planning to write a yesod web application. And I'm wondering whether there are some large project using yesod that is well designed that I could look at and experiment with.
I am looking for open source projects. I can learn from.

I've been developing a web application that focuses on media sharing mainly inside home network, and acted as a excercise for me.
This was the first project for me using Yesod, and in fact the first larger project written in Haskell, but maybe there is something to learn from it.
There's stuff like reused widgets, custom sql queries (could probably use esquelato nowadays), hashdb authentication/access control and plugin-like sections-thingy for handling different types of files in share.
Disclaimer: This is my personal project developed purely for my needs, and I have not had the time to upgrade the code base for Yesod 1.2 nor do I consider it stable or well-designed.
The source code: https://github.com/SimSaladin/rnfssp
An in-production demo can be found at https://ssdesk.paivola.fi

As an update for this answer there is now a page of these on the Yesod wiki, including the source for my own site.

Related

Question about commercial use of generated JHipster apps

I'd like to get some business apps up and running quickly with the use of JHipster, which seems like a solid approach; assuming it is allowed. Is the commercial use of a generated JHipster application allowed and if so, what are the proper steps to take in in order to not infringe upon any terms and conditions of open source?
I apologize if this has been asked previously.
I really just need to know how I can go about using an instance of a generated application for something other than an open-source project.
Sincerely,
Art
There are many closed source applications originally generated by JHipster. The generated project is fully yours.

How do I create transferable dll's for a specific website functionality?

VS2013 update 5, MVC5 using Areas
I have a stand-alone function programmed for a website. The functionality is a specific user interface to collect survey responses in a particular way. It has several controllers, a model and a group of views. The functionality is completely contained in an Area of the project, except for the Shared _Layout file that provides the main menu for consistency.
'Is it possible for me to' / 'how do I' compile this Area into a single or set of .dll file(s) that I could then add conveniently to other websites? I'm assuming creating something for transfer/download is very standard functionality. For example, I used Elmah.MVC for this site. What I want to do is pretty much create a package that can be downloaded in a similar way to how we integrate Elmah.MVC into a site. (Be certain I'm not talking about creating error logging software, I'm only using Elmah.MVC as an example of software that is easily integrated into other website applications.)
I've never compiled any website functionality into a .dll(s) for use elsewhere and would appreciate either some specific guidance, or perhaps what would be easier is to provide a link with a good step by step tutorial or explanation for how to do this. Most of what I've found on the web describes bits and pieces of doing this, but it's not enough for me to feel confident with it.
It seems to me there are a lot of 'moving parts' to taking a particular piece of an MVC application and turning it into something that is easily added to other projects.
A particular issue I don't quite grasp is the difference in downloaded packages between getting code and getting just the .dll(s). For instance, when I download an MVC5 site, I get controllers, models and views, but when I download Elmah I get a .dll and no code files. Also, I do understand the concept of transforms, but I'm just struggling right now with even getting from my programmed application into a 'package' regardless of the transforms that make it easy to integrate into another website.
These are just some of my questions I have about how to perform this particular process in developing deliverable and/or shareable software.
What you are looking to do is create a portable MVC Area project. A Portable Area is a set of reusable multi page functionality can be dropped into an application to provide rich functionality without having to custom build functionality that is literally the same in every application. An MVC Portable Area is really just a dll that contains the views, controllers, scripts, etc… needed to use in a website that is either a Web Forms website or an MVC website. A developer can use them for a reusable widget or a complete engine. I have actually used them for both. Here is a link with some basic info to get started. http://elegantcode.com/2012/04/06/mvc-portable-areas/

Getting started with Yesod

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.
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".

Comparing Haskell's Snap and Yesod web frameworks

The two Haskell web frameworks in the news recently are Yesod (at 0.8) and Snap (at 0.4).
It's quite obvious that Yesod currently supports a lot more features than Snap. However, I can't stand the syntax Yesod uses for its HTML, CSS and Javascript.
So, I'd like to understand what I'd be missing if I went with Snap instead. For example, doesn't look like database support is there. How about sessions? Other features?
Full disclosure: I'm one of the lead developers of Snap.
First of all, let's talk about what Snap is. Right now the Snap team maintains five different projects on hackage: snap-core, snap-server, heist, snap, and xmlhtml. snap-server is a web server that exposes the API defined by snap-core. heist is a templating system. xmlhtml is an XML/HTML parsing and rendering library used by heist. snap is an umbrella project that glues them all together and provides the powerful snaplets API that makes web apps composable and modular.
Yesod has a host of projects on hackage. Most (all?) of them are listed in the Yesod category. Some of the notable ones are yesod-core, warp, persistent, and hamlet.
The reality of Haskell web development is that it's much less of an exclusive-or choice than seems to be perceived. In general the projects are very loosely coupled and fairly interchangeable. You could build a website using warp (the Yesod team's web server), heist (the Snap team's template system), and acid-state (the Happstack project's persistence system). You could also use snap-server with hamlet or persistent.
That said, the two projects definitely have some differences. The biggest difference I can point out objectively is that Yesod projects typically make heavy use of Template Haskell and quasiquoting to create concise DSLs, while Snap projects stick to building combinator libraries that favor composability. Just about any other differences I can think of will be subjectively biased towards Snap. The umbrella packages named after both projects are obviously going to make specific choices for the above mentioned components, and these choices will be reflected in the project dependencies. But that still doesn't mean that you can't pull in something different and use it as well.
Snap does have sessions and authentication, interfaces to several databases, and nice form handling (here and here) using digestive-functors that includes prepackaged support for arbitrarily nested dynamically sizable lists. These are just some of the growing ecosystem of pluggable snaplets. The sessions and authentication snaplets are written in a way that is back-end agnostic. So with a small amount of glue code you should be able to use it with just about any persistence system you can think of. In the future, Snap will stick with this policy as often as possible.
For the most part I think the choice of Snap vs Yesod vs Happstack is less an issue of features and more one of personal taste. Whenever someone says that one of the frameworks doesn't have something that another one has, most of the time it will be pretty easy to pull in the missing functionality from the other framework by importing the necessary package.
EDIT: For a more detailed comparison of the big three Haskell web frameworks check out my recent blog post. For a rougher (but possibly more useful) comparison using some broader generalizations, see my Haskell Web Framework Comparison Matrix
Fair warning: I'm the lead developer of Yesod.
I'm not sure what you don't like about the Javascript syntax: it is plain javascript with variable interpolation. As for CSS Yesod now has Lucius which allows you to also use plain CSS. For HTML, you can easily use any other library you want, including Heist (what Snap uses). That said, it's a bit of a funny thing to skip Yesod over CSS/Javascript syntax, when Snap doesn't even have a syntax for it. You are certainly welcome to their solution of just static files.
Yesod comes with seamless support for authentication/authorization, type-safe URLs, widgets, email, and a bunch of little things all over the place (breadcrumbs, messages, ultimate destination). Plus, Yesod has a fairly rich set of add-on packages for things like comments and markdown, and a few large real-world code bases to pick at for examples. If any of these are attractive to you, you might want to check if your alternatives supports them.
Give hamlet a try- you might end up liking it. A negative reaction at a superficial level is not uncommon. However, nobody that has actually used hamlet complains.
Also, why not use Happstack? Just because they aren't "in the news" doesn't mean they don't have a solid framework.
You probably referring to old version of yesod. Latest yesod versions have plain syntax for html, javascript and css.
The html syntax of yesod's template library hamlet is plain html with complete opening and closing tags and all normal html attributes. Yes you can omit closing tags and use shortcuts for id and class attributes. But you do not have to. You can continue to write plain html.
Not only that but html templates can reside in separate files, just like in Snap's template library Heist.
Java script templates (julius) are plain javascript files, also residing in separate files.
The css template does indeed have a different syntax, but recent version of yesod now provides also plain css syntax.
If you go with Heist you will not have type safe urls.
In Heist html templates are read from harddrive everytime. Yesod compiles all templates directly into the executable. No file is read from harddrive. Thus the response is much faster. You can see the benchmarks yourself.
In Yesod you can create widgets that cooperate nicely. Snap does not deal with widgets at all. You will have to roll your own.

Developing a DotNetNuke CMS website

I am a junior developer and I have just graduated from university this year. I am working private with some people and I have just been given a music website to develop using DotNetNuke. I have a some experience using DotNetNuke which I have gained making small modules that take care of certain functionality on a webpages but I have never taken on a whole website before. I would love it if some one would give me some guidence on how to approach this project and answer some of my questions.
What are the steps involved in developing a dotnetnuke website?
How different is it from a developers perspective to develop a dotnetnuke cms website from a cms website which was developed from scratch?
When it comes to the database do you add tables to the database incrementally as you develop new functionality or do you plan everything in advance and create tables and stored procedures at once?
What are the steps involved in developing a dotnetnuke website?
Pick your version (if you're starting now, pick 5.1.1)
Installation (use Source package locally, Install package everywhere else)
Settings Configuration (performance, security, user info, etc.)
Adding & configuring core/third party modules
Adding & configuring third party skins
Custom Extension (typically module or provider) Development
Custom Skin Development
How different is it from a developers
perspective to develop a dotnetnuke
cms website from a cms website which
was developed from scratch?
Very. When you're starting with an established CMS you're inheriting solutions to tons and tons of solved problems. In the case of DNN, you have a substantial framework at your disposal. The focus will be more on learning and leveraging the existing API/features. If you're starting from scratch you're providing that foundation yourself. Using an established CMS is not necessarily better than the other - it depends on what you're trying to accomplish. If you require fine-grained control over everything and you want a great learning experience, rolling your own may be the best way to go.
When it comes to the database do you
add tables to the database
incrementally as you develop new
functionality or do you plan
everything in advance and create
tables and stored procedures at once?
No matter what your project is, I'd suggest doing things as they are needed and not before. I think "doing everything in advance" would be impossible/horrible anyway. The heart of this question is really going to be defining your development process - I don't think this would necessarily be any different than in other projects. I like to define the features I want, organize them based on their relation to each other (which should come first due to dependencies, etc) and start implementing them one at a time and give each one the attention it needs.
You may also want to look into Lee Sykes' tutorials on module development using OpenWebStudio. However, I'm more on the design end, mainly just skinning, configuring, SE optimizing sites and matching client needs to our library of licensed 3rd party modules. However, the DNN community is VERY supportive and VERY helpful. There are some great resources out there, and I've found several blogs by the core development team to be essential for helping me wrap my head around the DNN framework.
Keep with it, and don't be scared to ask questions.
References:
www.dnncreative.com - Lee Sykes' Site, many tutorials on the how-tos of the DNN system. It's well worth the yearly subscription IMHO.
www.dotnetnuke.com - The main site for the DNN community
www.snowcovered.com - Central (AFAIK) site where many module developers sell their products, everything from skins to modules.

Resources