Hacker News new | comments | show | ask | jobs | submit login

I have been wanting to look into Haskell for a long time now. Never really got the time. Also the syntax was a bit off putting.

Just skimmed through. I see that there is a bit of Javascript and C in the code too as reference matertial. Most people dont like such a way of teaching but it looks like the tutorial isnt really trying to teach Haskell in terms of Javascript or C. Really makes me want to look into this. Thanks for putting the efforts.

I'm a bit surprised that you say the syntax if offputting, most people I've met say otherwise. Could you point to something you specifically don't like?

I didnt mean in a sense that it sucks. Its way different from the traditional C style or Lisp style syntax that I've used. Regardless of whether it is good or bad, it would have taken me some time to adjust to it and I never had that kind of time.

Also as someone who doesn't know Haskell at all, I have great difficulty reading Haskell. I dont think I would have that kind of problem reading a language with a more traditional syntax.

Some Lisp:

  (defun foo (ls)
    (mapcar (lambda (x) (+ (f x) 2))
Trim unnecessary parenthesis (map is mapcar, \x -> … is lambda expr):

  foo ls =
     map (\x -> ((+) (f x) 2))
With infix syntax

  foo ls = map (\x -> f x + 2) ls
And only if you really want it:

  foo = map (\x -> f x + 2)

  foo = map ((+2) . f)

Thank you. That is some good way to look at it. I think people here assumed that I hated haskell or something. This breakdown actually makes it a lot clear to me. Thanks :)

I think some folks are misreading your comments a bit as an indictment of the language. I read it as saying, "Haskell doesn't have syntax that's similar to any language I know and that means I have to learn something I don't know, which takes time, and I don't have a lot of time."

Personally, I'm with you. I've used other functional languages (F#, clojure, erlang), I'd say I'm pretty familiar with a lot of the ideas Haskell uses (comprehensions, partial application, anonymous functions, pure functions, pattern matching) and I actually really want to learn Haskell, but I have a hard time intuiting the meaning of a lot of Haskell syntax just based on other syntax that I know.

I also realize that the syntax probably fits the language very well, which makes sense, and that it's a good thing. I wouldn't want it to compromise it's purity for familiarity. Just makes it more work to learn.

I'm with you, but you do get used to it. Basically if you just get your feet wet writing a few semi-significant programs in Haskell (e.g. a parser, which is a very common and pleasant task in Haskell), then you'll get familiar with it. The biggest hurdle for me came from being able to understand do-syntax (which is a bunch of applications of monadic bind).

Hah! yes. Maybe I should have put it the way you did.

My view of Haskell is the same as a non-Lispers view of Lisp. Cry about too much parens and it making things difficult to understand. Doesn't mean the language needs to be changed. I am all in for learning Haskell although most introductions to haskell are really time consuming and dense, so I never just did it. Which is where I was really glad that this tutorial was put up.

Hating any language which actually does serve its purpose is pretty stupid. If anyone actually has some issues understanding a sightly different but very well respected language, then the fault is mostly with that person and not the language.

I think lisp is a really good example for how I feel with haskell, and one I'm more familiar with.

When I first started learning lisp, the syntax was foreign, and while lisp syntax is arguably really really simple, composition with that syntax is a little weird if you're not used to it. Yet, at the same time, the syntax is a fundamental part of the language, especially with respect to homoiconicity, simplicity and macros. It was a time-sink to get used to it, but totally worth it.

very much agreed.

I like to recommend this article to people getting confused with Haskell's syntax: http://blog.ezyang.com/2011/11/how-to-read-haskell/

It concisely covers most of the syntax and some common idioms with prelude functions (such as using `$` and `.` to get rid of parenthesis)

Also as someone who doesn't know Haskell at all, I have great difficulty reading Haskell. I dont think I would have that kind of problem reading a language with a more traditional syntax.

Right, but then you'd lose the benefit of Haskell being a very different language. To implement Haskell using C-style syntax would make it extremely awkward to make liberal use of Haskell's powerful features. In particular, Haskell's syntax is optimized to make fully/partially applying functions as quiet as possible. This really shines in conjunction with the ability to define your own operators -- including their fixity -- so you can wage an all-out assault on parentheses!

Oh dear lord, you misunderstand me. I dont want to implement Haskell in C-style. Haskell is good being haskell, I just had difficulty understanding it and never had enough time to dive deep into it. But now I may.

That's good of you. This problem (familiarity) plagues many upstart technologies. Taking the generality even further, it could be argued that the status quo bias is one of the most difficult-to-overcome aspects of human nature and that its effects on society are extremely widespread.

Do you know any other functional language? If not, it's a problem not with syntax (Haskell syntax perfectly fits its semantics), but with what is actually going on in the program. Without firm grasp of FP concepts (recursion, currying, partial application, abstract data types, etc) almost any Haskell code seems to be alien.

I find a lot of people complaining about Haskell syntax without understanding how deeply different this language is from "usual" languages.

I think the problem might be also things that look like syntax to somebody who is not used to Haskell, but are just usual functions like ($) (<*>) ($!) and whatnot.

I really wish Haskell syntax was extended to allow special forms ("case", "do", etc) to be ordinary function arguments and not just infix function arguments.

This would remove a significant portion of the $ signs in Haskell programs, as so many of them are just padding for "do", "case", etc.

I agree. There are a fair number of symbols out there. And really, how do you pronounce: ">>=", "<<=", "<*>", ".", and such.

I know them now, but discoverability is pretty low on those functions.

And Control.Lens introduces around 20 more symbols like this. It does at times feel like reading perl without 'use English;'

Yes I do know FPs a great deal. I DO NOT harbor any kind of hate towards Haskell, just never found it easy to understand(or read, to be more specific). Also this link makes me want to learn it more than ever now.

The syntax has more in common with Python than anything else I know of--it seems pretty readable to me.

Now the structure of Haskell is going to be very alien if you're used to imperative languages (C, Python, what have you). You mention Lisp, so that should give you as good a background as anything else in terms of reading Haskell code.

The syntax is much closer to Lisp than C, really. The main differences from Lisp are lack of macros (so slightly more actual syntax) and function application (in particular infix functions). Most things you see are functions.

"slightly more actual syntax" is where all the syntax is, though :)

"do", "let", "where", "case", "class", "instance", records, ...

There's a lot more syntax to learn than in Lisp, but it is IMO the best designed syntax of all languages I've used prior to Haskell. It is much less noisy and less painful than the C-family syntax.

I do remember it being so different was an obstacle for the first couple of weeks of learning Haskell, and even being grumpy about "why did they have to choose a syntax so foreign" at that point :)

It's still a tiny amount of syntax, even compared to the likes of Python (I'm not comparing to C++ as that wouldn't be fair).

It is generally an actually designed syntax and works quite well. My point was that most of the unusual things are just function calls.

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