Re: [Haskell-cafe] Tutorial uploaded

2005-12-21 Thread Ketil Malde
Paul Moore [EMAIL PROTECTED] writes:

 One thing I'd consider adding is something along the lines of a section:

 == So how do I write Hello, world? ==

I've gone and done it.  I've perhaps been heavy handed on the original
page, so feel free to complain and/or fix it.

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Tutorial uploaded

2005-12-20 Thread Paul Moore
On 12/20/05, Daniel Carrera [EMAIL PROTECTED] wrote:
 Hi all,

 I've finished a first draft of what I call First steps in Haskell.
 It's intended to be the very first thing a new user sees when they
 decide to try out Haskell.

 http://www.haskell.org/hawiki/FirstSteps?action=show

 It's a bit longer than I'd like, but I don't inmediately see anything I
 can take out without losing something valuable (given the purpose of
 this document).

 Thoughts and comments?

It looks very good. The length isn't a problem to me, if anything I'd
be happy expanding a little.

One thing I'd consider adding is something along the lines of a section:



== 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.

To deal with the distinction between functional and imperative code,
Haskell uses a construct called the IO monad. It's not hard to
understand - basically, it's just a way of wrapping up imperative
code so that there's a clear boundary between it and functional code -
but most tutorial presentations of Haskell start with functional code,
and introduce the IO monad later.

As a taster, though, here is Hello, world in Haskell:

{{{
module Main where

main :: IO ()
main = putStrLn Hello, World!
}}}

Put this in a file called hello.hs, and compile it with `ghc -make
hello.hs -o hello`. You'll get an executable called hello (or
hello.exe on Windows). Run it to see the output.

There will be plenty more on writing standalone programs, IO, and
other aspects of the IO monad, as you learn more about Haskell.



The point is, people *will* want to write hello, world, so don't put
them off by making it seem hard. Show them how, explain where they
will find out more, and explain why things like this come naturally at
a later stage when learning Haskell than they do with, say, C.

Paul.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] Tutorial uploaded

2005-12-20 Thread Bayley, Alistair
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Daniel Carrera
 
 Hi all,
 
 I've finished a first draft of what I call First steps in Haskell. 
 It's intended to be the very first thing a new user sees when they 
 decide to try out Haskell.
 
 http://www.haskell.org/hawiki/FirstSteps?action=show
 
 Thoughts and comments?


There's not much wrong with doing a Hello World:

  main = putStrLn Hello World

Or:

  fac n = if n = 0 then 1 else n * fac (n-1)
  main = print (fac 12)


Compiling, or at least running a haskell script (via runhaskell) should
also get a mention, so you show how to achieve things outside of the
interactive prompt.

Alistair
*
Confidentiality Note: The information contained in this message,
and any attachments, may contain confidential and/or privileged
material. It is intended solely for the person(s) or entity to
which it is addressed. Any review, retransmission, dissemination,
or taking of any action in reliance upon this information by
persons or entities other than the intended recipient(s) is
prohibited. If you received this in error, please contact the
sender and delete the material from any computer.
*
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe