5 ms·
Pretty awesome, I've steered clear of Haskell preferring Scala instead (easier syntax for me to grok), but this tutorial makes Haskell far more accessible. Off
by virtualwhys 13y ago
Pretty awesome, I've steered clear of Haskell preferring Scala instead (easier syntax for me to grok), but this tutorial makes Haskell far more accessible.
Off topic but does anyone know of a Rails/Play + Linq to SQL/ScalaQuery equivalent in Haskell?
Beyond that just being able to generate PDF invoices, send out emails and have access to a decent date/time library (like JodaTime) would cover the essentials for web development.
- ocharles 13y agoFor Rails/Play, we have three web frameworks: * Snap * Yesod * Happstack I think all of these have techniques to build web sites in a modular fashion, but I have only used Snap myself. For querying, I personally just use postgresql-simple and write SQL strings, but this tends to be a major source of runtime bugs so I'm reconsidering that. For type safe alternatives, we have things like HaskellDB (http://chrisdone.com/posts/haskelldb-tutorial http://chrisdone.com/posts/haskelldb-tutorial) and esqueleto (http://hackage.haskell.org/package/esqueleto-1.3.4.2/docs/Database-Esqueleto.html http://hackage.haskell.org/package/esqueleto-1.3.4.2/docs/Da...). We have a fairly decent date time library in time (http://hackage.haskell.org/package/time http://hackage.haskell.org/package/time) but I don't know if that matches JodaTime (because I don't JVM libraries). For PDF generation I'm actually not sure at all - but have a search on http://hackage.haskell.org http://hackage.haskell.org and there may be something.
- virtualwhys 13y agoThanks, I did check out Yesod and HaskellDB a while back when I was researching ways to escape from Grails hell (i.e. pre grails 2.0). Yesod looked promising, HaskellDB, not so much (IIRC was developed in early 2000s and not actively maintained). Definitely not interested in going back to string based SQL after working with ScalaQuery for the past couple of years. Anyway, the thrust of the question was, can you do full stack web dev with Haskell. The answer seems to be yes, but you have to dig around a bit. Would be a fun side project to hack together a site in Haskell, definitely a fan of the type system
- asdf1234 13y agoFor anything other than trivial queries ScalaQuery/Slick generates very bad SQL. I'd like to use it but generating deeply nested sub-queries when simple joins would suffice is totally unacceptable. The PostgreSQL query optimizer can fix them in the simple cases but the MySQL and Oracle optimizers can't and it causes performance to drop off a cliff. HaskellDB suffers from a similar problem.
- virtualwhys 13y ago> For anything other than trivial queries ScalaQuery/Slick generates very bad SQL For Slick, yes, but for ScalaQuery 0.10, absolutely not. All of my ScalaQuery generated SQL is semantically _exactly_ what I would have written by hand, and completely typesafe, with generated prepared statements to boot. This includes outer join based queries, subselects, and other operations that cause Slick to generate nightmare SQL (why I'm avoiding Slick until the library is stable on the performance front). I love ScalaQuery, but Slick, TBD, they have a ways to go yet, the new Scala collections syntax with groupBy and sortBy is particularly hideous compared to ScalaQuery's SQL based groupBy and sortBy. The Slick team will sort things out, hopefully sooner rather than later (for example, I'd love to have Slick 2.0's composable parameterized query snippet functionality, that alone is a huge boilerplate WIN).
- enigmo 13y agotime (sadly) isn't comparable to Joda Time.
- virtualwhys 13y agoJodaTime is unbelievably awesome. That's one of the reasons why being on the JVM with Scala, Clojure, etc. makes one's coding life simpler: huge ecosystem to draw on with minimal effort (i.e. rarely need to roll your own).
- tel 13y agoAs someone who has never used Joda Time, what makes it so great?
- virtualwhys 13y agoGenerally immutable (supports mutable state for some edge cases) along incredibly rich functionality covering everything you could imagine needing time-wise, and does so concisely. It's a godsend given the built-in Java alternative.
- jcurbo 13y agoocharles covered pretty much everything else but for PDF generation I would look into pandoc, the Swiss Army knife of document conversion. It can be used as a standalone program or as a Haskell library.
- PeterisP 13y agoIn Haskell, Yesod felt Rails-like to me; take a look at the scaffolded site example according to the instructions at http://www.yesodweb.com/page/quickstart http://www.yesodweb.com/page/quickstart - it takes just a few minutes and if you take a look at the sample site and the code for the root page, it should give you an impression on what's its style.
- Dewie 13y agoI find Haskell's to be relatively simple, while Scala's seem to be all over the place. Probably not weird since Scala tries to straddle 2-3 different worlds/paradigms.
- virtualwhys 13y agoFor the general case I'd argue that Scala's syntax is far easier to sort out for anyone coming from C-based langs. However, yes, for complex type hierarchies, heavily curried functions, and other higher level approaches, Haskell obviously wins, equivalent Scala code is a mess in comparison. Odersky recently tweeted an EPFL paper addressing simplification of the type system (that got Scala FP devotees up in arms); i.e. in the not too distant future we may have fewer ways to do the same-ish thing (a good thing, IMO, if the language can be trimmed down, at a minimum that bodes well for current portability issues).
- Dewie 13y ago> For the general case I'd argue that Scala's syntax is far easier to sort out for anyone coming from C-based langs. Before I learned about either, I had most experience with Java. Though I'm biased since I learned Haskell first (and I wouldn't say that I 'know' Scala).