Live data from Hacker News

Reading Simple Haskell

soupi.github.io

31–40 of 82 posts

Re: Reading Simple Haskell

#31
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…

That is his point, I think. He doesn't want to be exposed to errors related to whitespace in the code. I feel the same way, and it's the number one reason I avoid Python.

Re: Reading Simple Haskell

#32

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…

> Which is partly why OCaml gets some bias from me over Haskell.

Sounds like you made a mistake, then, because indentation is optional in Haskell: https://en.m.wikibooks.org/wiki/Haskell/Indentation#Explicit...

Re: Reading Simple Haskell

#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 of the paper, after the author's conclusion, is a transcript of the discussion at the conference. The first question is from Naur:

Regarding indentation, in many ways I am in sympathy with this, but I believe that if it came about that this notation were used for very wide communication and also publication,you would regret it because of the kind of rearrangement of manuscripts done in printing, for example. You very frequently run into the problem that you have a wide written line and then suddenly you go to the Communications of the ACM and radically, perhaps, you have to compress it. The printer will do this in any way he likes; he is used to having great freedom here and he will foul up your notation.

Next, Floyd:

Another objection that think is quite serious to indentation is that while it works on the micro-scale—that is, one page is all right—when dealing with an extensive program, turning from one page to the next there is no obvious way of indicating how far indentation stretches because there is no printing at all to indicate how far you have indented. I would like you to keep that in mind.

It's a very old discussion.

Re: Reading Simple Haskell

#35
post #19

Earlier quoted context omitted.

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

>omit braces so you're saying braceless ifs and fors are bad? yes I agree. > close the wrong brace -/+ 1 flipping the right number of braces to get that kind of bug is much much harder than indenting a block incorrectly

But the requirement for always having brackets is just plain inconvenient for many. Even C doesn't always require brackets.

Re: Reading Simple Haskell

#36
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…

There were problems with printing APL programs - those strange symbols. Or unclosed brackets and quotes. J tried to address these issues, it's ASCII-only - yet J code still looks rather unstructured.

This argument may sound like admission of imperfectness of printing process.

Re: Reading Simple Haskell

#37
post #25
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…

This example is very contrived, but challenge accepted.. main = do let print = putStr . (++ " ") in do print "happy" print "holidays" -- indentation sensitive putStrLn "!" De-indenting the marked line by 2 spaces exposes some scroogey irony. (Note that compiler warnings give a hint about the bad idea in this code, but nested do's can have this problem without warnings also.)

I'm not sure that's what GP meant. I understood what he said as "it's hard to write code which correct in logic, types, and which passes correct beautifier which changes logic", and I'd think this is impossible.

The example you gave requires to change logic - because indentation is a part of the logic here.

Re: Reading Simple Haskell

#38
post #16

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…

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.

Re: Reading Simple Haskell

#39
post #2

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 .

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.

Re: Reading Simple Haskell

#40
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…

Beautifying C, for example, also can be tricky in the presence of nested comments

C comments do not nest.

Post reply on HN