
Comparing Haskell Web Frameworks - tikhonj
http://edofic.com/posts/2014-02-23-haskell-web.html
======
losvedir
Yesod is surreal.

I experimented with it at one point and tried to change a form field from
required to optional. Boom! The whole application wouldn't compile...

The properties of the form are reflected in the type system and changing
required to optional changed the type. That means I had to track the effect
through the application and everywhere that just assumed the data was there
had to be updated to handle both cases.

It was so restrictive and confusing I gave up for the time being (until I
learn Haskell better), but it was an eye-opening glimpse of the power of
types.

~~~
Tehnix
That's actually one of the reasons I like it. Instead of allowing your
application to live in a half-working state, you're required to fix such
things.

While it might not be as instantly gratifying and being able to refresh and
see the page is still working, in the long run it saves a lot of headache.

~~~
jes5199
I would strongly prefer to work in an environment that detected the error and
gave me the power to trace through the app to resolve it _while still letting
the damn program run in the mostly-working state_. The mental cost to review
hundreds of lines of code to work out the implications of every change before
you can _see_ any results is a problem - it breaks the creative flow, it
prevents experimentation.

~~~
chongli
_The mental cost to review hundreds of lines of code to work out the
implications of every change before you can see any results is a problem - it
breaks the creative flow, it prevents experimentation._

Type errors don't require such a mental cost. Once you learn how to actually
read the error messages it becomes almost brain-dead simple. Compile, jump to
the error message (hopefully your editor can help here), fix, recompile.

 _it breaks the creative flow, it prevents experimentation._

I disagree. What prevents experimentation is the fear of the unknown
regression. Strong types give you the reassurance you need to boldly refactor
without worrying that you'll miss something.

------
Tehnix
I personally haven't tried the alternatives, but did research them when before
I initially settled on Yesod.

Coming from a background of web dev'ing in Python and PHP, I've come to
absolutely love Yesod. What I love most about it is that when it compiles, I'm
99% sure it works the way I intended it. This is a huuuuge plus, since I've
been used to always having to test in runtime, which adds a lot of overhead
and possibility for oversight.

This might just be me falling completely in love with Haskell and type
inference (not just static typing, Java -.-..), but I'd wager that for any
larger codebase/project, the gain from the time saved debugging, would make
Haskell (and IMHO Yesod) the optimal choice.

~~~
Swizec
Nitpick: Haskell IS statically typed.

~~~
h_r
I think he's saying he likes the type inference in addition to the static
typing (no inference in Java).

------
tel
Some more annotated resources:

1\.
[http://www.haskell.org/haskellwiki/Web/Comparison_of_Happsta...](http://www.haskell.org/haskellwiki/Web/Comparison_of_Happstack,_Snap_and_Yesod)

A relatively complete listing of resources comparing the three major
framework/libraries. A lot of this information is outdated, sadly.

2\. [http://stackoverflow.com/questions/5645168/comparing-
haskell...](http://stackoverflow.com/questions/5645168/comparing-haskells-
snap-and-yesod-web-frameworks)

A SO question about comparing Snap and Yesod where both maintainers chime in.
The major point of talking here is the Yesod style "Template Haskell"
configuration.

3\.
[http://www.reddit.com/r/haskell/comments/l0fne/what_should_i...](http://www.reddit.com/r/haskell/comments/l0fne/what_should_i_use_for_web_programming/)

A similar question posed to /r/haskell with a great comment by yogostoth
demonstrating Yesod.

4\. [http://softwaresimply.blogspot.com/2012/04/hopefully-fair-
an...](http://softwaresimply.blogspot.com/2012/04/hopefully-fair-and-useful-
comparison-of.html)

A relatively balanced view comparing the three feature by feature. Again a bit
outdated, but well-informed.

5\. [http://softwaresimply.blogspot.com/2012/12/haskell-web-
frame...](http://softwaresimply.blogspot.com/2012/12/haskell-web-framework-
matrix_20.html)

And finally my favorite summary of the whole thing: the Web Framework matrix
which considers each as a web programming embedded DSL and talks about their
relative merits in a 2x2 table.

------
virtualwhys
Yesod looks very interesting.

If I jump ship from Scala + Play framework to Haskell, Yesod will be my first
choice, batteries included and then some.

Anyone know if a Haskell IDE is in the works? Certainly would help to be able
to mouse hover-view type, or mouse click-go to source declaration a la
Eclipse/IntelliJ/Visual Studio, etc., particularly for beginners, imagine
that's a pretty big time sink in learning the language...

~~~
niels
There is eclipsefp. [http://eclipsefp.github.io/](http://eclipsefp.github.io/)

~~~
virtualwhys
Thanks, am an Eclipse user so this might be just what the doctor ordered ;-)

------
polymatter
Sorry for the hijack, but if anyone has any tips on Haskell debugging, please
share. I loved Yesod, and get such satisfaction when it compiles because of
the confidence it gives me that its working as intended. I love the type safe
routes :) But I find debugging to be 99% what I do and I am terrible at it.

Also, any decent Haskell IDEs out yet? I'm using emacs purely for the syntax
highlighting. I tried leksah but I gave up trying to configure it properly on
my box.

~~~
ixmatus
You should study Haskell types. Debugging anything in Haskell without a basic
understanding of the type system is _daunting_.

Additionally, Yesod relies heavily on quasiquoting and template haskell which
can lead to some very cryptic code and errors. I generally prefer Snap for
this reason and many others.

~~~
polymatter
I find I spend most of my time on the engineering than in understanding types.
(I recommend 'Types and Programming Languages by Pierce for general type stuff
and Typeclassopedia for Haskell specific). Though I confess Yesod is the first
real time I've seen quasiquoting and template haskell before. I haven't yet
got a familiarity of what certain errors mean. 50% of the time when I get a
compile error, the error message seems to be off on a complete tangent and is
nowhere near where the actual error was.

Eg. I had some problem where a Data.Text was being passed into a function
where Data.Text.Lazy was expected (Network.Mail.Mime.simpleMail for the
record). The error message was deep in the internals of Data.Text.Lazy rather
than in my code. I had to play a ridiculous pecking game of using undefine on
each time I use Data.Text in turn in order to find which particular Data.Text
was causing the error and then explicitly force one particular argument type
to be a Data.Text.Lazy. I didn't feel like the compiler helped me at all.

Stepping through a program linearly doesn't seem possible (though not entirely
sure why not) so I have no intermediate or step through capability. I also
can't (normally) just stick in a println in the middle of a function or view
the data structures at any particular point of the program. These are two
tools I use all the time with Java and C#, but in Haskell I am rendered blind.

~~~
tene
[http://hackage.haskell.org/package/base-4.6.0.1/docs/Debug-T...](http://hackage.haskell.org/package/base-4.6.0.1/docs/Debug-
Trace.html) is what you want to use for emitting debug text or debug data
dumps.

------
taejo
I've used Yesod for a small webapp. The type-safety is amazing.

For a simpler project, I've used a small subset of Snap. Well, the HTTP side
was simpler: it was a game with the front-end completely in JS, and the server
in Haskell; all Snap did was shunt JSON back and forth through a few routes
for creating a new game, getting the updated game state, posting a move, etc.

Both are nice, depending on what you need, but for your average Django or RoR
developer, Yesod gives the most bang for the buck in terms of learning a
completely different paradigm.

------
arianvanp
`Applicative`'s `<|>` should be `Alternative`'s `<|>`. Alternative is to
Applicative what MonadPlus is to Monad. Actually MonadPlus can be defined with
just Applicative laws and no Monad laws, that's why MonadPlus will be replaced
by Alternative in GHC 7.8.

------
nkuttler
This is a nice introduction but doesn't really cover much. As a primarily web
dev who's just learning some haskell I'd be happy to hear more about data
models, controllers, view, etc, whatever there is.

~~~
dobbsbob
That's why all the documentation to those projects is linked in this brief
intro. Yesod has an entire book too
[http://www.yesodweb.com/book](http://www.yesodweb.com/book) though I haven't
read it, I assume it covers what you're looking for

~~~
nkuttler
Very nice thanks. I guess I was just being lazy :)

------
embwbam
As a beginner, if you're looking for something a little more familiar try
Scotty - [https://github.com/scotty-web/scotty](https://github.com/scotty-
web/scotty)

It's just like using Sinatra or Express. It doesn't provide any url type-
safety or magic, but that is also why it is easier to use.

------
danieldk
Ehm:

 _One more step Please complete the security check to access edofic.com_

Google Cache works though.

