pozorvlak recently
discovered a bit of a gotcha in writing haskell examples:
If I'm in emacs, and I write this:
tick = do n <- get; put (n+1); return n;
on three lines, it comes out like this:
tick = do n <- get
put (n+1)
return n
This is because emacs has a particularly smart indent mode - it notices the "do", and realises that I
(
Read more... )
Comments 3
tick = do n <- get
And press enter, the auto-indent will align with the n, as it should. Seems to require vim7, though.
It's no comparison to haskell-mode for emacs, but it's better than default vim indentation. Of course, your suggestion works as well. :)
Reply
I would still like to argue though, that when writing code that's primarily intended to be read rather than run - particularly by beginners (so, library docs and particularly tutorials), the extra line is worthwhile.
This is because I think that beginners can't be expected to fully understand haskell indentation rules (at least in this much detail) right from the start. I also think it's unreasonable to expect them to be using one of vim or emacs.
When I'm writing example code, I'd like a beginner to be able to naively copy-type it into notepad, and have it work first time.
Reply
Thanks again!
Reply
Leave a comment