ndmitchell:
Hi
Having got to the word counting example on the website:
wordcount :: IO () wordcount = do wc <- wordcount' False 0 putStrLn (show wc) where wordcount' inword wc = do ch <- getc case ch of Nothing -> return wc Just c -> handlechar c wc inword handlechar c wc _ | (c == ' ' || c == '\n' || c == '\t') = wordcount' False wc handlechar _ wc False = wordcount' True $! wc + 1 handlechar _ wc True = wordcount' True wc
Eeek. That's uglier than the C version, and has no abstract components.
A much simpler version:
main = print . length . words =<< getContents
Beautiful, specification orientated, composed of abstract components.
My thoughts too when reading the initial post was that it was all very low level imperative programming. Not of the Haskell flavour. -- Don