Live data from Hacker News

Reading Simple Haskell

soupi.github.io

71–80 of 82 posts

Re: Reading Simple Haskell

#71
post #64
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!

It doesn’t even work on iOS safari.

You can view this as markdown on github[0]

[0]: https://github.com/soupi/rfc/blob/master/reading_haskell.md

Re: Reading Simple Haskell

#72
post #33

Earlier quoted context omitted.

The simplicity with which a new operator is defined.

I think this is a downside. It just makes reading new code that uses esoteric symbols defined elsewhere.

This[0] operator glossary reviews the most used operators.

[0]: https://haskell-lang.org/tutorial/operators

Re: Reading Simple Haskell

#74
post #63

I like the content but: I 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 presen…

Thanks! fixed.

You can find the document and repo here:

https://github.com/soupi/rfc/blob/master/reading_haskell.md

Re: Reading Simple Haskell

#75
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!

I'm sorry for that. I'll try to fix this when I can. For now you can view the markdown document instead of the slides here:

https://github.com/soupi/rfc/blob/master/reading_haskell.md

Re: Reading Simple Haskell

#76
post #67

Earlier quoted context omitted.

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.

One fun thing is how -> is basically just an infix operation that takes two types as arguments and returns a new type. add :: (->) Int Int add x y = x + y

It's the function type, data (->) a b. It is commonly written in infix notation though.

Re: Reading Simple Haskell

#77

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.

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

Also, comments are considered to be lexemes for this purpose.

Re: Reading Simple Haskell

#78

Earlier quoted context omitted.

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

Internally, Python is a lot like that, too - like in Haskell, the lexer adds in brace tokens when the code is indented an unindented, which keeps the grammar simpler. I guess the main difference here is that Haskell exposes the underlying whitespace-insensitive notation to the programmer, too, whereas Python keeps it hidden.

Haskell is also a LOT more lenient. So stuff like

    if x 
is legal.

Re: Reading Simple Haskell

#79
post #32

Earlier quoted context omitted.

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

I have never seen a Haskell dev do this.

Simon Peyton Jones, one of the driving forces behind GHC, uses braces.

Re: Reading Simple Haskell

#80
post #17

Earlier quoted context omitted.

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.

Since C99, you've been able to have end-of-line comments inside a block comment.
Post reply on HN