3 ms·
> "=>" means comparison In what language? Did you mean ">=" or "<="? They mean the exact same thing in Haskell. > "|" means an OR It also means the same thin
by jolmg 7y ago
> "=>" means comparison
In what language? Did you mean ">=" or "<="? They mean the exact same thing in Haskell.
> "|" means an OR
It also means the same thing in Haskell.
data Maybe a = Nothing | Just a
"data of type `Maybe a` is either `Nothing` OR `Just a`."
max a b | a > b = a
| otherwise = b
"max of a and b is either a when a > b OR b otherwise."
odd x || x >= 5
"x is odd OR x is greater than or equal to 5"
A cool thing about Haskell is that it lets you define new operators. In the parsec package, you get the operator <|>, which keeps the meaning of OR but works with parsers.
csvCell = csvQuotedCell <|> csvNonQuotedCell
"a CSV cell is either a quoted cell OR a non-quoted cell".
> I'm cringed to see $s and \s in a program code that makes it look like LaTeX
I don't think they're so common that the comparison is valid. $s implies Template Haskell, which should be used sparingly. \s implies lambdas, which are nowhere near as common as the use of backslashes in LaTex.
> I also prefer the boundary of terms and expressions to be consistently marked up with parenthesis.
The way you wrote this, makes me think you prefer to write 2 + 5 * 2 as 2 + (5 * 2). You can do that, just like in any other language. I don't think it's common to add parenthesis redundantly in any language though.
If you actually meant something like preferring f x y to be written as f(x, y), it's not just a matter of taste. It's so the syntax makes sense with partial application. You can do
f x y = ...
g = f x
h = g y
and it would be more confusing to write
f(x, y) = ...
g = f(x)
h = g(y)
- tome 7y ago> $s implies Template Haskell I think it's more likely to mean function application ...
- jolmg 7y agoAt least, I've never seen someone use the `$` operator and put the right operand without any spacing in between. Not only would it cause errors on activating Template Haskell because GHC would interpret it as a TH splice[1], but also it would be weird to read because one tends to use the `$` operator when they have a multi-term expression they would otherwise not want to parenthesize. For example, take a look at this line in Yesod[2]: $logInfo $ pack $ show (a, b, c) The one without a space is a Template Haskell splice and the ones with a space are using the function application operator. If logInfo didn't need to be expanded by Template Haskell and we deactivate that extension, we could write: logInfo $pack $show (a, b, c) But I doubt anyone would because the implied parentheses around those operators are: (logInfo) $((pack) $((show) (a, b, c))) [1] https://downloads.haskell.org/~ghc/7.8.4/docs/html/users_guide/template-haskell.html https://downloads.haskell.org/~ghc/7.8.4/docs/html/users_gui... [2] https://github.com/yesodweb/yesod/blob/c8aeb61ace568cdc2bc81d54f75c1a7d40ad3324/yesod-core/helloworld.hs#L40 https://github.com/yesodweb/yesod/blob/c8aeb61ace568cdc2bc81...
- tome 7y agoYes, but I suspect euske, being unfamiliar with Haskell, just used an unfamiliar form.