4 ms·
"Lisp is known for hating infix notation, but Haskell embraces it. ... There are ten levels of operator precedence (0 through 9)" This is one of the things I p
by jimbokun 17y ago
"Lisp is known for hating infix notation, but Haskell embraces it. ... There are ten levels of operator precedence (0 through 9)"
This is one of the things I prefer about Lisp. Am I the only one who still has to stop and think occasionally about what binds more tightly with what when reading and writing code in languages with many precedence levels? Never a problem in a Lisp.
- tel 17y agoI appreciate both, honestly. Lisp achieves a great deal through purity of syntax, but that sort of thing was never Haskell's goal. Personally, I almost never think about how precedences compare; instead you learn a Haskell coding style that support the syntactic tricks allowed by operator precedence. A pretty common one goes something like this: forM [1..] $ \n -> do a <- monadicAction1 n b <- monadicAction2 a return b Which is sort of ugly from a Lisp point of view, but I think it's a great trick enabled by having $ be an ultra-low precedence sequencing combinator. It looks like a Ruby block almost, but has zero extra syntax and very clear semantics.
- shrughes 17y agoI haven't noticed it being a problem in Haskell. Most of Haskell's weird operators are either uncommon enough so that everybody uses parentheses with them (such as bitwise (.|.) and (.&.) and so on), common enough that you don't forget (but (&&) and (||) are the two I always forget, and occasionally some people don't use parentheses with them), or weird and common but it's very hard to use them incorrectly without getting a compile error ((.) and ($) and (>>=) and (<$>) and (<*>) and (++) and (:) and (&&&) and so on). I don't think most of the operators in the last list would be usable without static type checking. In particular, operators like ($) and (.) are hugely beneficial and the latter's existence is one of the main reasons people like Haskell's syntax.