Live data from Hacker News

Reading Simple Haskell

soupi.github.io

51–60 of 82 posts

Re: Reading Simple Haskell

#51
post #13

This 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!

While I agree STRONGLY, I just tested after seeing your comment and it led me to try the Reader mode in FF which worked perfectly and thus allows full zooming of this site.

Wow, thank you for introducing me to that feature!

Re: Reading Simple Haskell

#53
post #44

Earlier quoted context omitted.

Yeah, I think the real problem I have is the impossibility of opting out of the indentation style. Not using any indentation or newlines seems pretty extreme. All I want to do is write it like it was C, and that’s not possible (maybe we need yet another extension)

> Not using any indentation or newlines seems pretty extreme. You can certainly use indentation and newlines, my examples were just demonstrating the ability to "obviously" not invoke layout since there's nowhere layout information can be. Whether to use layout (braceless) or explicit structuring (braceful) is solely determined by a brace being present after a listed keyword, you can have any whitespace you want arou…

Thank you. Need to spend a bit more time grokking this.

Re: Reading Simple Haskell

#54
post #34

I once downloaded a python script, ran it with some input, and got a result. Curious, I opened the script in Emacs, which then opened it into python mode. As is my habit, I indented the whole file, which did basic white space changes to it according to python mode. I didn't realize I did this at first, and I saved and exited the script, then played around with it some more. Still got results, everything seemed the sa…

In 1965, Peter Landin presented the groundbreaking paper "The Next 700 Programming Languages" at the ACM Programming Languages and Pragmatics Conference in San Dimas. It described a family of languages called ISWIM, with a staggering number of durable inventions. It's widely recognized as the precursor to ML and Haskell. One of the inventions is the "off-side rule" for indentation sensitive parsing. The last section…

Last time that I printed a program to work on it was probably 25 years ago.. I don't really think that it makes any sense at all as of today. And if you are really indenting so much that you can't understand the indentation then it's a clear sign of something wrong in your code.

Re: Reading Simple Haskell

#55
post #19

Earlier quoted context omitted.

honestly it's bananas. I can't for the life of understand how such a poor form over function decision was ever made by an engineer. the number of bugs (>0) this introduces into production code every year is reason enough (imho the only relevant metric) to prefer braces. are block delimiting braces really that onerous???

Because braces don't introduce bugs? You can just as easily omit braces in a if/for etc statement and have a bug, or close the wrong brace at the wrong point (and also introduce a bug).

I can upvote you only once sadly..

Re: Reading Simple Haskell

#56
Haskell 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

#57
post #16

Earlier quoted context omitted.

I'm not entirely sure if you are implying that wrong indentation in Haskell will result in programs that compile, but give differing output? I have honestly never seen that happen, and couldn't imagine a piece of code that would compile in either cases. EDIT: 1) as masklinn mentions, the indentation in Python and Haskell works differently. Furthermore, Python can have expressions as top-level, which Haskell cannot, a…

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.

Re: Reading Simple Haskell

#58
post #17

I once downloaded a python script, ran it with some input, and got a result. Curious, I opened the script in Emacs, which then opened it into python mode. As is my habit, I indented the whole file, which did basic white space changes to it according to python mode. I didn't realize I did this at first, and I saved and exited the script, then played around with it some more. Still got results, everything seemed the sa…

You used a buggy beautifier that mishandled some code, and you blame significant whitespace? For that to be valid criticism, it must be particularly hard to write a beautifier for languages with significant whitespace relative to other languages. I don’t think it is. Beautifying C, for example, also can be tricky in the presence of nested comments (potentially of different types) and nested if statements, some withou…

Mixing tabs and spaces in Python leads to ambiguities.

Actually, in Haskell too, but as the GP said, it is almost impossible that it becomes a problem on practice.

Re: Reading Simple Haskell

#60
post #8

One 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.

Re indentation, you might find these two useful https://en.wikibooks.org/wiki/Haskell/Indentation and http://echo.rsmw.net/n00bfaq.html .

That helped thanks!
Post reply on HN