On Tue, Mar 4, 2008 at 4:16 AM, Ketil Malde <ke...@malde.org> wrote: > Paul Johnson <p...@cogito.org.uk> writes:
> > I'm surprised you found the significant whitespace difficult.
> I wonder if this has something to do with the editor one uses? I use > Emacs, and just keep hitting TAB, cycling through possible alignments, > until things align sensibly. I haven't really tried, but I can > imagine lining things up manually would be more painful, especially > if mixing tabs and spaces.
Especially if mixing tabs and spaces indeed. Haskell does the Python thing of assuming that a tab is 8 spaces, which IMO is a mistake. The sensible thing to do if you have a whitespace-sensitive language that accepts both spaces in tabs is to make them incomparable to each other; i.e.
main = do <sp><sp>putStrLn $ "Hello" <sp><sp><tab>++ "World" -- compiles fine
main = do <sp><sp>putStrLn $ "Hello" <tab>++ "World" -- error, can't tell how indented '++ "World"' is...
That was an interesting read. Thanks for posting it. I also liked the tale of the BBC ULA - it reminded me of a demo I saw once at an Acorn show, where they had a RISC PC on show, with a (IBM) PC card in it. They were demonstrating how hot the PC chip runs compared to the ARM RISC chip by using it to make toast. I dread to think what you could do with one of today's monsters :-)
> On Tue, Mar 4, 2008 at 4:16 AM, Ketil Malde <ke...@malde.org> wrote: > > Paul Johnson <p...@cogito.org.uk> writes:
> > > I'm surprised you found the significant whitespace difficult.
> > I wonder if this has something to do with the editor one uses? I use > > Emacs, and just keep hitting TAB, cycling through possible alignments, > > until things align sensibly. I haven't really tried, but I can > > imagine lining things up manually would be more painful, especially > > if mixing tabs and spaces.
> Especially if mixing tabs and spaces indeed. Haskell does the Python > thing of assuming that a tab is 8 spaces, which IMO is a mistake. The > sensible thing to do if you have a whitespace-sensitive language that > accepts both spaces in tabs is to make them incomparable to each > other; i.e.
<snip>
I honestly think that tab characters occurring anywhere but in a comment should be considered a lexical error and rejected by the compiler outright. More problems are caused by trying to continue with only tabs, or some mixture of tabs and spaces than just getting one's editor to expand tabs automatically.
> Especially if mixing tabs and spaces indeed. Haskell does the Python > thing of assuming that a tab is 8 spaces, which IMO is a mistake. The
FWIW, most people in python land think the same thing, and the -t flag makes mixed tabs and spaces a warning or error. At the least, -Wall could report mixed usage. At the most, make it an error. _______________________________________________ Haskell-Cafe mailing list Haskell-C...@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
As for the idle core you mention: I keep one core fully occupied with a program that searches for a cure against cancer, see: http://www.computeagainstcancer.org/
The example you gave for the use of "map" can be simplified: map func (take (10 [0..])) -- should actually be: map func (take 10 [0..]) -> map func [0..9]
On Tue, 04 Mar 2008 07:29:24 +0100, Alan Carter <alangcar...@gmail.com> wrote:
> Many thanks for the explanations when I was first experimenting with > Haskell. I managed to finish translating a C++ wxWidgets program into > Haskell wxHaskell, and am certainly impressed.
> I've written up some reflections on my newbie experience together with > both versions, which might be helpful to people interested in > popularizing Haskell, at:
> I've written up some reflections on my newbie experience together with > both versions, which might be helpful to people interested in > popularizing Haskell, at:
maxofHistogram stats = foldl' max 0 (map snd stats)
("foldl' max 0" could be replaced by "maximum" but there wouldn't be a default 0 anymore)
more importantly, you can replace this kind of code : vA <- varCreate [] vB <- varCreate [] -- ... vL <- varCreate [] vM <- varCreate [] vN <- varCreate [] vO <- varCreate []
(true also for the "dA <- textEntry statusFrame [text := "0", alignment := AlignRight]" sequence)
I'm not sure that functions like getdTotal couldn't be improved, I wonder if a small Map for the elements of d wouldn't make the code much better and offer other opportunities for abstractions. As it is, enumeration like :
could be slightly reduced by : let bindLabelAndWidget (lbl,getter) = [label lbl, widget (getter d)] in map bindLabelAndWidget [("Total Entries", getdTotal), ("Valid Entries", getdValid) ,(...)]
And little thing like : mapM_ (\f -> do repaint f) knownFrames becoming : mapM_ repaint knownFrames
I also do concur that a flag or a warning to signal mixed tabulations and space would be a _very_ good idea !
> 2008/3/4, Alan Carter <alangcar...@gmail.com>: > > I've written up some reflections on my newbie experience together with > > both versions, which might be helpful to people interested in > > popularizing Haskell, at:
Thanks for an interesting write-up. And not bad for a first Haskell program. :) There's still a number of things you could do to limit the boiler plate code, though.
On Tue, Mar 4, 2008 at 6:29 AM, Alan Carter <alangcar...@gmail.com> wrote: > Many thanks for the explanations when I was first experimenting with > Haskell. I managed to finish translating a C++ wxWidgets program into > Haskell wxHaskell, and am certainly impressed.
> I've written up some reflections on my newbie experience together with > both versions, which might be helpful to people interested in > popularizing Haskell, at:
> -- > ... the PA system was moaning unctuously, like a lady hippopotamus > reading A. E. Housman ..." > -- James Blish, "They Shall Have Stars" > _______________________________________________ > Haskell-Cafe mailing list > Haskell-C...@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe