Hacker News new | past | comments | ask | show | jobs | submit login
Developing Web Applications with Haskell (docs.google.com)
130 points by corey on July 4, 2015 | hide | past | favorite | 32 comments



That is a good summary of the options for Haskell web development. The author of this slide deck also wrote "Beginning Haskell." I bought this book and like it. That said I have an addiction to buying Haskell books :-) Personally, I use Yesod for complicated apps, otherwise Spock.


That was definitely a good book, would recommend it as well.


I'll also chime in and say the same. I've been meaning to go back and complete the exercises I couldn't at first.

I almost got stuck not reading on because I couldn't figure out how to do some exercises but I'm glad I didn't because hindsight shows me that would have been a mistake.


Based on your recommendations, just now, I went to go check out the book and found they're having a one-day half-price sale on it at Apress, the publishers:

http://www.apress.com/9781430262503?gtmf=s

Nice timing. Buying now. Thanks for the tip.


I'm somewhat new to web dev and new to functional programming. Can someone tell me how this is fundamentally different that ClojureScript + OM (https://github.com/omcljs/om) ?


Fundamentally, I guess the difference is that one is type-safe, and the other isn't.

You can get compile time errors instead of runtime for bunch of things.


ClojureScript also, I think, has a better front-end story for squishier front ends at the moment (although there are a number of projects working on changing that).


It looks like a good start. I've been trying to learn Haskell and F Sharp and other functional languages and always wondered if there was a web option.


Suave.io for F# is very nice http://suave.io/


I'd like to see something like this, but with JSON-based APIs instead of HTML templating.



(Author here) There is a set of exercises that come with the slides at https://github.com/serras/lambdaconf-2015-web In particular, they introduce the Aeson library for both producing and consuming JSON.


You should check out PostgREST, a tool to expose Postres tables through a JSON APIs: https://github.com/begriffs/postgrest


I believe the HTML templating stuff is pretty optional in all the major Haskell web platforms. I know in Yesod it is trivial to serve JSON rather than HTML from an end-point, and pretty easy to serve multiple representations of the same resource.


"aeson" is the go-to library for producing and parsing JSON in Haskell.


thoughtbot's carnival is a good example of a JSON API written with Yesod: https://github.com/thoughtbot/carnival


What's the most rails or django-esque framework for haskell?


Yesod.


Does it support a "React" style of building web applications?


What would have to be different in a web application for it to be able to support the "React" style of building web applications?


Don't forget about reflex[0], you can try it here[1].

I also use purescript[2] with purescript-halogen[3] as does slamdata[4]. There's also a video on Purescript halogen[5] that's very interesting.

Purescript is great because the JavaScript it generates is so readable, that if you really need to you can understand the output and make micro-optimizations.

0: https://github.com/ryantrinkle/reflex

1: https://github.com/ryantrinkle/try-reflex

2: http://purescript.org/

3: https://github.com/slamdata/purescript-halogen

4: http://slamdata.com/

5: https://www.youtube.com/watch?v=AbDX-wRigAo


Thanks for the links! I'm really curious about what Haskell can come up with for a front-end story.

Do you think that Purescript's row typing (as seen in records and the Eff monad/effect system) is a viable replacement for monad transformer stacks? I "get" MT stacks but I find them heavyweight when what is most often desired is commutative set building of capabilities rather than MT-style stacking.


Monad transformers and PureScript's row-based effects are two complementary approaches to the problem of extensible effects.

Some effects in PureScript look a lot like the effects provided by certain monad transformers (StateT/ST/Ref, ExceptT/Exception, etc.), but there are differences in terms of how things compose. Take StateT and ExceptT for example: you can compose them in two ways, and get two different monad transformer stacks, with different behaviors (surrounding how state propagates when an exception occurs). There are valid use cases for each, but with the ST and Exception effects, there is only one way to combine them: the way the underlying (Javascript) runtimes chooses for us.

There are things which each one can do which the other cannot. Fortunately, we can mix and match in PureScript since we have the purescript-transformers library. A typical arrangement is to stick Eff on the bottom of a monad transformer stack.

_Edit_: of course, everything you can do with a monad transformer can be done more verbosely with pure functions and the underlying monad, so you _could_ replace monad transformers with Eff in many cases, but in practical terms, it might not be all that useable in some cases.


Consider mtl then. It provides commutative capability set building semantics from the user's POV and then only asks the consumer to make final stack-ordering/effect specification decisions.


I find mtl pretty close to a sweet spot. The one thing I wish for is to be able to constrain effect order as a user (using your terminology above) when I'm writing code where one ordering or another is incorrect. The closest I can come is to fix the top of the stack, which suffices for correctness but puts some unnecessary burden on the consumer.


My solution is to make a new typeclass which implies the order you demand. It'll all be social contract driven, but until we have dependent types one cannot ask for more.


Ah, good call!


I think you'll find this interesting: https://www.youtube.com/watch?v=4nTnC0t7pzY


There are a number of Haskell-to-JS compilers and Haskell-alike languages which more directly target JS. This is growing quickly but major issues remain and the toolkits are quite immature.

On the other hand, much of React is a natural play out of Haskell's sweet spot. The challenge will be in making Js-alike APIs which handle the flexibility well while maintaining sufficient typing. React-like rendering, virtualdom, data flow... this will all be incredibly naturao.


I recently had a great experience with GHCJS, although I wouldn't really say I'm using it in anger.


I find it pleasant every time I get something working in it... but significantly far away from anything I'd like to support in production. At least for now.





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: