[Haskell-cafe] Re: Tutorial uploaded
Sebastian Sylvan
sebastian.sylvan at gmail.com
Tue Dec 20 14:07:29 EST 2005
On 20 Dec 2005 19:52:31 +0100, Peter Simons <simons at cryp.to> wrote:
> > == So how do I write "Hello, world"? ==
> >
> > Well, the first thing you need to understand that in a
> > functional language like Haskell, this is a harder
> > question than it seems. Most of the code you will write
> > in Haskell is "purely functional", which means that it
> > returns the same thing every time it is run, and has no
> > side effects. Code with side effects is referred to as
> > "imperative", and is carefully isolated from functional
> > code in Haskell.
>
> I believe this description is a bit misleading. Code written
> in the IO monad is purely functional just the same. Haskell
> knows no other code than purely functional one. In my humble
> opinion, it's unfortunate that many tutorials and
> introductionary texts leave the impression that monadic code
> would be something utterly different than "normal" Haskell
> code. I feel it intimidates the reader by making a monad
> appear like black magic, even though it's little more than
> syntactic sugar to describe implicit function arguments.
>
> If we'd have an opaque "World" type instead of the IO monad,
> 'putStrLn' would be:
>
> putStrLn :: String -> World -> World
>
> How is this function any different from any other function?
> So why should
>
> putStrLn :: String -> IO ()
>
> be different from any other function?
>
It's sometimes beneficial to "lie" a bit when starting out. Perhaps
say something like "this is a simplified view of things, for all the
gory details see chapter 19".
Monadic IO is pretty darn cool, sadly that means that many tutorial
authors are tempted to spend pages upon pages explaining exactly why
it's cool and how it works, but that is NOT what most people starting
out with the language need to read.
I'm still looking for a good *practical* tutorial that I could
recommend to newcomers.
IO, data types and QuickCheck in the very first chapter, I say! Real
program examples from the get go, and go into the theory on why this
has been hard in FP before Haskell (or Monadic IO rather) much much
later, so as to not scare people away.
/S
--
Sebastian Sylvan
+46(0)736-818655
UIN: 44640862
More information about the Haskell-Cafe
mailing list