[Haskell-cafe] Haskell & monads for newbies
andrewcoppin at btinternet.com
Sun Jul 15 12:08:16 EDT 2007
Steve Schafer wrote:
>> "basically everything I write programs for is mainly about I/O..."
> It's funny how people always seem to think that, but if you look at what
> they're really doing, I/O is usually the least of their worries.
> Programming GUIs is about the only reasonably common I/O-related task
> that has any sort of complexity. Most everything else is reading or
> writing streams of bytes; the hard part is what happens between the
> reading and the writing.
Indeed, I replied "if all you want to do is run some algorithm over some
data, you can write a thin layer to do the I/O, and then write the rest
in pure code". And everybody was like "er, I don't understand what
distinction you think you're making..."
Obviously, what I meant is that one can write
main = do
stuff <- readFile "source.txt"
writeFile "source.exe" $ compile stuff
compile = ...
I guess because in most normal programming languages you can do I/O
anywhere you damn like, it doesn't occur to most programmers that it's
possible to make a seperation. (Most seem to realise that, e.g., mixing
business logic with GUI code is a Bad Thing though...)
I saw a quote somewhere round here that went like this:
"Haskell isn't really suited to heavily I/O-oriented programs."
"What, you mean like darcs?"
More information about the Haskell-Cafe