3 ms·
A cursory skim leaves the impression of just how alone Haskell is on many syntactic choices (though supposedly with alot in common with "Merd".) I never took t
by mdcox 12y ago
A cursory skim leaves the impression of just how alone Haskell is on many syntactic choices (though supposedly with alot in common with "Merd".) I never took the time to learn Haskell, but it always looks beautiful on an aesthetic level, which differentiates it from the other loners in the list.
Can anyone point me to any papers/documentation/discussion on WHY certain syntax decisions were made? Many could have been arbitrary choices to match the constructs, but the way the community presents itself makes me think there's more to it.
- tome 12y agoHaskell inherits a lot from Standard ML. This paper explains a lot of the design decisions of Haskell, syntax amongst them: http://haskell.cs.yale.edu/wp-content/uploads/2011/02/history.pdf http://haskell.cs.yale.edu/wp-content/uploads/2011/02/histor...
- Retra 12y agoThe best part of Haskell is that function application is just whitespace. f x = f(x) I would attribute almost 90% of it's elegance to that idea alone. (This is not an exact number or measured estimate.) I also have a major thing for pattern-matching, and it always seems nice when you know that's what you're looking at. For instance, it is far easier to understand what `int * * var` is in C if you see it as a kind of pattern de-structuring.
- tormeh 12y ago>The best part of Haskell is that function application is just whitespace. It's the worst part, in my opinion. Is A B C D equal to A(B(C(D))), A(B,C,D), A(B,C(D)), A(B(C),D) or A(B(C,D))? Often you need to disambiguate with parentheses, so I guess there is some default interpretation that you can assume when reading code, but in the end it just looks like an unnecessary mental translation step. Lisp has weird syntax, but lisp has a reason to have that syntax. Haskell has a weird syntax because it wants to either be different for different's sake or to just be plain inaccessible.
- gamegoblin 12y agoA B C D is necessarily equal to A(B,C,D) in C-family syntax due to the precedence rules, there is no ambiguity. The reason whitespace is more elegant is because your functions can return other functions, which due to function currying and partial application is equivalent to your function simply taking more arguments. I'll use Python as an example. def flip(f): return lambda a,b : f(b,a) That is, it's a function that takes a function of two arguments, and returns a function that does the same thing, but with the argument order flipped. To use these function, it would look like: flip(f)(a,b) In Haskell, a direct translation with the lambda would be: flip f = \a b -> f b a The type of which could be written as: flip :: (a -> b -> c) -> (b -> a -> c) That is, a function which takes one argument, that argument is a function that takes two arguments of types a and b and yields a value of type c, and returns a function that takes two arguments of types b and a and yields a value of type c. We could use this function like: (flip f) a b But due to function precedence we could use flip f a b This segues into an equivalent (and arguably better) way to write the function taking advantage of partial application and currying: flip :: (a -> b -> c) -> b -> a -> c flip f a b = f b a Which would be used the exact same way: flip f a b This illustrates the elegance of currying. a -> b -> c Is equivalent to a -> (b -> c)
- TazeTSchnitzel 12y agoAll Haskell functions are curried, so there's no ambiguity.
- epidemian 12y agoConsider that, in Haskell: 1. all functions take a single argument (i.e., are curried) 2. function application is left-associative So "a b c d" is just applying the function "a b c" with the argument "d", the same as "(a b c) d". "a b c" is the application of "c" to the function "a b", which, in turn, is the application of "b" to "a". So "a b c d" is the same as "((a b) c) d". I personally find using the space symbol for a core concept of the language (function application) very elegant, and not dissimilar to other languages that strive to have simple and consistent syntax, like Smalltalk, where "obj meth1 meth2 meth3" is the same as "((obj meth1) meth2) meth3", even though Haskell and Smalltalk might be as different as programming languages can get :)