Unrelated: I'm obviously quite biased, but I generally like Haskell code for pseudo code like things, because it does away with a lot of syntax specific cruft, and stays close to the math it's usually talking about. Also, readers might be interested in A Tour of Go in Haskell, which is the concurrency chapter of A Tour of Go, but just...in Haskell - https://a-tour-of-go-in-haskell.syocy.net/en_US/index.html .
Reading Simple Haskell
61–70 of 82 posts
Re: Reading Simple Haskell
#62One thing this doesn't mention, which might be useful to know, is that Haskell is indentation-sensitive. For instance, those examples using "let" won't compile if the lines beginning with "let" and "in" aren't indented. I'd be interested if anyone knows of a simple guide to Haskell's indentation rules - I still find it trips me up now and then.
> Haskell is indentation-sensitive. That's not really true, at least not in the way Python is. Haskell is actually defined using "braceful" syntax, and that syntax can be used anywhere (and is useful for code generation); on top of that it has Layout Rules[0]. Basically: Any time a "where", "let", "do" or "of" keyword is not followed by a brace, an implicit one is inserted and the indentation of the next lexeme (non-…
Re: Reading Simple Haskell
#63I can't link to the slide because of the way these pages are defined:
slide 11: The presented argument order in the ASCII-art of Red, Blue, Green I think should be Red, Green, Blue to match the usual initialism.
I could not find a way to submit a pull-request for this presentation, and my search-fu on github failed to find the associated repo, and there were no links I could find in the presentation to submit comments.
Re: Reading Simple Haskell
#64This site breaks the zoom function in Firefox. Please be considerate towards the visually impaired, and don't break zoom on one of the few browsers that actually even have a somewhat useful zoom function!
Re: Reading Simple Haskell
#65Earlier quoted context omitted.
Ocaml isn't whitespace sensitive (other than in the obvious sense, i.e., to separate tokens). You can write a whole module (or series of modules) on a single line if you want to.
You can write a whole module in a single line of Haskell too. That's not the correct thing to test.
Ocaml uses whitespace (including newlines) for exactly one reason: token separation. Indentation and line breaks are arbitrary, and can be replaced with spaces in any sequence of Ocaml statements. The same cannot be said for Haskell.
Re: Reading Simple Haskell
#66Earlier quoted context omitted.
You can write a whole module in a single line of Haskell too. That's not the correct thing to test.
Really? How do you put multiple "import" statements on a single line in Haskell? Or a function signature followed by its definition? Ocaml uses whitespace (including newlines) for exactly one reason: token separation. Indentation and line breaks are arbitrary, and can be replaced with spaces in any sequence of Ocaml statements. The same cannot be said for Haskell.
With semicolons and curly braces; Haskell's newline/indent syntax is merely an aesthetic substitute for those.
Re: Reading Simple Haskell
#67Unrelated: I'm obviously quite biased, but I generally like Haskell code for pseudo code like things, because it does away with a lot of syntax specific cruft, and stays close to the math it's usually talking about. Also, readers might be interested in A Tour of Go in Haskell, which is the concurrency chapter of A Tour of Go, but just...in Haskell - https://a-tour-of-go-in-haskell.syocy.net/en_US/index.html .
Agreed -- I found Haskell most confusing at first because of the lack of syntax. My brain kept wondering where the rest of the syntax was. Not to be too dramatic, but I think Haskell is kind of like programming "poetry" in this regard.
I realized pretty early on all these were just functions, that was cool experience for me. Even the types are sort of functions.
Re: Reading Simple Haskell
#68Haskell can be very readable and elegant, but what I do find frustrating is when research papers show sample Haskell, but it's not quite Haskell. They just can't seem to resist the urge to replace various operators and types with their own non-alphanumeric symbols, thus making what should be reading simple code into some kind of hieroglyphic translation exercise..
Re: Reading Simple Haskell
#69Unrelated: I'm obviously quite biased, but I generally like Haskell code for pseudo code like things, because it does away with a lot of syntax specific cruft, and stays close to the math it's usually talking about. Also, readers might be interested in A Tour of Go in Haskell, which is the concurrency chapter of A Tour of Go, but just...in Haskell - https://a-tour-of-go-in-haskell.syocy.net/en_US/index.html .
Go is impoverished compared to Haskell but not when it comes to concurrency. The Haskell analogues for these concurrency primitives seem laborious...and they were even moreso prior to the advent of the `async` library.
[0] https://www.reddit.com/r/haskell/comments/7ilhb9/a_tour_of_g...
[1] https://hackage.haskell.org/package/gochan-0.0.2/docs/Contro...
Re: Reading Simple Haskell
#70Earlier quoted context omitted.
Agreed -- I found Haskell most confusing at first because of the lack of syntax. My brain kept wondering where the rest of the syntax was. Not to be too dramatic, but I think Haskell is kind of like programming "poetry" in this regard.
When I first start I though there was so MUCH syntax, (->), ( ), ( ), (>>=), (.), ($), etc I realized pretty early on all these were just functions, that was cool experience for me. Even the types are sort of functions.
add :: (->) Int Int add x y = x + y