First steps in Haskell

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
43 messages Options
123
Reply | Threaded
Open this post in threaded view
|

First steps in Haskell

Daniel Carrera-2
Hello all,

I'm trying to write the simplest possible Haskell program, and I'm not
getting anywhere.

I have installed Hugs, GHC and GHCI. I want to run the following program:

fac :: Integer -> Integer
fac 0 = 1
fac n | n > 0 = n * fac (n-1)

This is what I see:

$ hugs
Hugs.Base> fac :: Integer -> Integer
ERROR - Undefined variable "fac"
Hugs.Base> fac 0 = 1
ERROR - Syntax error in input (unexpected `=')


$ ghci
Prelude> fac :: Integer -> Integer

<interactive>:1:0: Not in scope: `fac'
Prelude> fac 0 = 1
<interactive>:1:6: parse error on input `='

$ # Write the program to fac.hs
$ ghc fac.hs

fac.hs:1:0:
     The main function `main' is not defined in module `Main'
     When checking the type of the main function `main'



This is a real problem for Haskell. I expect that a lot of people try
Haskell and give up because they can't even write the simplest function.
It's hard not to be put off by this. I love the theory behind Haskell,
but the practice of it seems to be a real problem.

I hope someone will show me how to make this program work. Even better,
I hope someone will fix the compilers and interpreters if they need
fixing, or fix the documentation if that's what needs fixing.

Best,
Daniel.
--
      /\/`) http://oooauthors.org
     /\/_/  http://opendocumentfellowship.org
    /\/_/
    \/_/    I am not over-weight, I am under-tall.
    /
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: First steps in Haskell

Lemmih
On 12/18/05, Daniel Carrera <[hidden email]> wrote:

> Hello all,
>
> I'm trying to write the simplest possible Haskell program, and I'm not
> getting anywhere.
>
> I have installed Hugs, GHC and GHCI. I want to run the following program:
>
> fac :: Integer -> Integer
> fac 0 = 1
> fac n | n > 0 = n * fac (n-1)
>
> This is what I see:
>
> $ hugs
> Hugs.Base> fac :: Integer -> Integer
> ERROR - Undefined variable "fac"
> Hugs.Base> fac 0 = 1
> ERROR - Syntax error in input (unexpected `=')
>
>
> $ ghci
> Prelude> fac :: Integer -> Integer
>
> <interactive>:1:0: Not in scope: `fac'
> Prelude> fac 0 = 1
> <interactive>:1:6: parse error on input `='
>
> $ # Write the program to fac.hs
> $ ghc fac.hs
>
> fac.hs:1:0:
>      The main function `main' is not defined in module `Main'
>      When checking the type of the main function `main'

GHC is a compiler. If you want to compile to a binary then you must
define a function called 'main'. Otherwise just load the file in ghci
(`ghci fac.hs`).

--
Friendly,
  Lemmih
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: First steps in Haskell

Chris Kuklewicz-2
In reply to this post by Daniel Carrera-2
Daniel Carrera wrote:

> Hello all,
>
> I'm trying to write the simplest possible Haskell program, and I'm not
> getting anywhere.
>
> I have installed Hugs, GHC and GHCI. I want to run the following program:
>
> fac :: Integer -> Integer
> fac 0 = 1
> fac n | n > 0 = n * fac (n-1)
>

$ ghci

Prelude> let { fac :: Integer -> Integer; fac 0 = 1; fac n | n > 0 = n * fac (n-1) }
Prelude> fac 12
479001600



>
> This is a real problem for Haskell. I expect that a lot of people try
> Haskell and give up because they can't even write the simplest function.
> It's hard not to be put off by this. I love the theory behind Haskell,
> but the practice of it seems to be a real problem.
>
> I hope someone will show me how to make this program work. Even better,
> I hope someone will fix the compilers and interpreters if they need
> fixing, or fix the documentation if that's what needs fixing.
>
> Best,
> Daniel.

Almost everything is explained under

http://www.haskell.org/ghc/docs/6.4.1/html/users_guide/ghci.html

The main things is: The ghci prompt accepts either command, starting with a color such as :load
"filename" or haskell IO code, since it is in a do-block. Thus let is required.

The 2-D Layout syntax does not work at the ghci prompt, thus the braces-and-semicolon style I used.

More typically you would write your code in a file, as shown in:
http://www.haskell.org/ghc/docs/6.4.1/html/users_guide/ch03s02.html
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: First steps in Haskell

Joel Koerwer-2
In reply to this post by Daniel Carrera-2
Try ghci fac.hs. You will then have an interactive session with access to the definitions in your file.

Then after you've played with you creation a bit, check out http://haskell.org/learning.html

Welcome and enjoy!

Joel

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: First steps in Haskell

haskell-2
In reply to this post by Daniel Carrera-2
Daniel Carrera wrote:

>> Hello all,
>>
>> I'm trying to write the simplest possible Haskell program, and I'm not
>> getting anywhere.
>>
>> I have installed Hugs, GHC and GHCI. I want to run the following program:
>>
>> fac :: Integer -> Integer
>> fac 0 = 1
>> fac n | n > 0 = n * fac (n-1)
>>


$ ghci

Prelude> let { fac :: Integer -> Integer; fac 0 = 1; fac n | n > 0 = n *
fac (n-1) }
Prelude> fac 12
479001600




>>
>> This is a real problem for Haskell. I expect that a lot of people try
>> Haskell and give up because they can't even write the simplest function.
>> It's hard not to be put off by this. I love the theory behind Haskell,
>> but the practice of it seems to be a real problem.
>>
>> I hope someone will show me how to make this program work. Even better,
>> I hope someone will fix the compilers and interpreters if they need
>> fixing, or fix the documentation if that's what needs fixing.
>>
>> Best,
>> Daniel.


Almost everything is explained under

http://www.haskell.org/ghc/docs/6.4.1/html/users_guide/ghci.html

The main things is: The ghci prompt accepts either command, starting with
a color such as :load
"filename" or haskell IO code, since it is in a do-block. Thus let is
required.

The 2-D Layout syntax does not work at the ghci prompt, thus the
braces-and-semicolon style I used.

More typically you would write your code in a file, as shown in:
http://www.haskell.org/ghc/docs/6.4.1/html/users_guide/ch03s02.html


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: First steps in Haskell

Daniel Carrera-2
In reply to this post by Lemmih
Lemmih wrote:
> GHC is a compiler. If you want to compile to a binary then you must
> define a function called 'main'. Otherwise just load the file in ghci
> (`ghci fac.hs`).

I would expect GHC to be able to compile a program with a function that
is not called 'main'. I wouldn't expect it to print anything when run,
but I would expect it to compile.

`ghci fac.hs` doesn't give any errors. I don't understand why loading
the file like that is ok but typing the entries is not. This might be a
problem for people exporing the language.

Best,
Daniel.
--
      /\/`) http://oooauthors.org
     /\/_/  http://opendocumentfellowship.org
    /\/_/
    \/_/    I am not over-weight, I am under-tall.
    /
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: First steps in Haskell

Daniel Carrera-2
In reply to this post by Chris Kuklewicz-2
Chris Kuklewicz wrote:
> Almost everything is explained under
>
> http://www.haskell.org/ghc/docs/6.4.1/html/users_guide/ghci.html

Ok. How would a visitor to the Haskell site find this document? If this
is the correct document for a beginner to start with Haskell, perhaps
the site should be updated to point to it instead of the documents it
currently points to.

I find some usability problems in the documentation section. Think of
usability in terms of barriers. If you have low barriers, a lot of
people will have enough motivation to cross them and get started with
Haskell. If the barriers are very high, only the most intent and
motivated users will get started. Barriers are bad.

Consider some barriers for a user who wants to learn Haskell:

* There's no way for a new user to figure out how to successfully run
the simplest Haskell program.
* The first tutorial listed requires the user to give up some personal
information before getting the tutorial.

These are very significant barriers.

Sure, it's not all bad. For example, Haskell has a friendly community
(low barrier). But the barriers that exist are a problem because they
hit the person who is trying to take the very very first step. If you
can make that *fist* step easier, more people will take it.

> The main things is: The ghci prompt accepts either command, starting
> with a color such as :load "filename" or haskell IO code, since it
> is in a do-block. Thus let is required.

I understand that the design of Haskell might force this behaviour (I
don't know, but I guess it must). The best solution I can think of (from
a usability POV) is to provide a very brief tutorial, just 1/2 page,
just enough to get someone through "hello world", and put it right at
the top of the Learning Haskell section. I would remove the Intro
section (it would fit better on the front page) and replace it with a
1/2 page tutorial. Something like this:

-------------// Sugestion -------------
40-SECOND INTRO TO HASKELL

(You must have <link>Hugs or GHC installed</link>)

1. Open a text editor and type:
fac :: Integer -> Integer
fac 0 = 1
fac n | n > 0 = n * fac (n-1)

2. Save as "fac.hs"
3. On a terminal:

$ ghci
Prelude> :load fac.hs
Compiling Main             ( fac.hs, interpreted )
Ok, modules loaded: Main.
*Main> fac 12
479001600

4. Press Ctrl+D to exit.

For more information, look at the following tutorials:
-------------// Sugestion -------------

There. That's brief, and it's enough to get the user past the first
step. It sends the message that Haskell is not so scary.


> More typically you would write your code in a file, as shown in:
> http://www.haskell.org/ghc/docs/6.4.1/html/users_guide/ch03s02.html

Thanks.

Best,
Daniel.
--
      /\/`) http://oooauthors.org
     /\/_/  http://opendocumentfellowship.org
    /\/_/
    \/_/    I am not over-weight, I am under-tall.
    /
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: First steps in Haskell

Daniel Carrera-2
In reply to this post by Joel Koerwer-2
Joel Koerwer wrote:
> Then after you've played with you creation a bit, check out
> http://haskell.org/learning.html <http://haskell.org/learning.html>

Thank you. I did find that page, and it was very easy to find. The
problem is that the content of that page, and its links, didn't show me
how to write a Haskell program (like you did).

Best,
Daniel.
--
      /\/`) http://oooauthors.org
     /\/_/  http://opendocumentfellowship.org
    /\/_/
    \/_/    I am not over-weight, I am under-tall.
    /
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: First steps in Haskell

Sebastian Sylvan
In reply to this post by Daniel Carrera-2
On 12/18/05, Daniel Carrera <[hidden email]> wrote:
> Lemmih wrote:
> > GHC is a compiler. If you want to compile to a binary then you must
> > define a function called 'main'. Otherwise just load the file in ghci
> > (`ghci fac.hs`).
>
> I would expect GHC to be able to compile a program with a function that
> is not called 'main'. I wouldn't expect it to print anything when run,
> but I would expect it to compile.

It can. To compile a module use the "-c" ('c' for "compile"). If you
want an executable you will need to have an entry-point (which is
main).

Typically you would write your program in a file, have a main
function, and then write

ghc --make MyMainModule.hs -o MyExecutableName

Optionally adding "-O" or "-O2" for optimisation.

The "--make" flag is really useful as it will cause GHC to track down
dependencies automatically and compile them if needed (reducing the
need for makefiles etc.).

/S

--
Sebastian Sylvan
+46(0)736-818655
UIN: 44640862
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: First steps in Haskell

Cale Gibbard
In reply to this post by Daniel Carrera-2
The ordinary usage pattern, which I recall is actually described in a
number of the tutorials, and on the wiki, probably in a number of
places, is to write your program text into a file with an editor, and
then load it at a terminal with either ghci fac.hs or hugs fac.hs.
(See http://www.haskell.org/hawiki/HaskellNewbie/HaskellInterpreterUsage,
as that's a conglomeration of a few of the question/answers that were
scattered about)

At that point, you can evaluate *expressions* at the ghci/hugs prompt,
to observe the operation of your program (think of it like a
debugger). This is different from entering declarations in that you
can't define things. GHCi specifically allows function/value
declarations with let (as it is somewhat emulating the inside of a
do-block), but it won't allow other kinds (data declarations, etc.).
"let x = 5 in x * x" works in either one, as it is an expression.

Note that you can type :r at the ghci or hugs prompt to reload your
file whenever you save it in your editor, so it's fairly easy to keep
things in sync.

If you want to compile your program with ghc proper, you'll need a
main action. Otherwise, well, what would the produced binary do? A
simple main is provided by printing some value, so I could add to your
program

main = print (fac 1000)

and then compile it, and the binary produced would print the integer
value of 1000! to the terminal.

Note that the interactive environments would have a hard time loading
ad-hoc Haskell code on stdin, as there may be, for instance, mutually
recursive bindings, and data types used in one function might be
declared later in the file. (Thus, testing that function would result
in an error message which currently isn't possible, a run-time type
error.) Further, the layout rule complicates the issue as to whether a
given line was intended as an expression, or the first part of a
declaration. I think it would be more confusing than what we currently
have.

Hope this helps,
 - Cale

On 18/12/05, Daniel Carrera <[hidden email]> wrote:

> Hello all,
>
> I'm trying to write the simplest possible Haskell program, and I'm not
> getting anywhere.
>
> I have installed Hugs, GHC and GHCI. I want to run the following program:
>
> fac :: Integer -> Integer
> fac 0 = 1
> fac n | n > 0 = n * fac (n-1)
>
> This is what I see:
>
> $ hugs
> Hugs.Base> fac :: Integer -> Integer
> ERROR - Undefined variable "fac"
> Hugs.Base> fac 0 = 1
> ERROR - Syntax error in input (unexpected `=')
>
>
> $ ghci
> Prelude> fac :: Integer -> Integer
>
> <interactive>:1:0: Not in scope: `fac'
> Prelude> fac 0 = 1
> <interactive>:1:6: parse error on input `='
>
> $ # Write the program to fac.hs
> $ ghc fac.hs
>
> fac.hs:1:0:
>      The main function `main' is not defined in module `Main'
>      When checking the type of the main function `main'
>
>
>
> This is a real problem for Haskell. I expect that a lot of people try
> Haskell and give up because they can't even write the simplest function.
> It's hard not to be put off by this. I love the theory behind Haskell,
> but the practice of it seems to be a real problem.
>
> I hope someone will show me how to make this program work. Even better,
> I hope someone will fix the compilers and interpreters if they need
> fixing, or fix the documentation if that's what needs fixing.
>
> Best,
> Daniel.
> --
>       /\/`) http://oooauthors.org
>      /\/_/  http://opendocumentfellowship.org
>     /\/_/
>     \/_/    I am not over-weight, I am under-tall.
>     /
> _______________________________________________
> Haskell-Cafe mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: First steps in Haskell

Cale Gibbard
In reply to this post by Daniel Carrera-2
On 18/12/05, Daniel Carrera <[hidden email]> wrote:

> Chris Kuklewicz wrote:
> > Almost everything is explained under
> >
> > http://www.haskell.org/ghc/docs/6.4.1/html/users_guide/ghci.html
>
> Ok. How would a visitor to the Haskell site find this document? If this
> is the correct document for a beginner to start with Haskell, perhaps
> the site should be updated to point to it instead of the documents it
> currently points to.
>
> I find some usability problems in the documentation section. Think of
> usability in terms of barriers. If you have low barriers, a lot of
> people will have enough motivation to cross them and get started with
> Haskell. If the barriers are very high, only the most intent and
> motivated users will get started. Barriers are bad.
>
> Consider some barriers for a user who wants to learn Haskell:
>
> * There's no way for a new user to figure out how to successfully run
> the simplest Haskell program.
> * The first tutorial listed requires the user to give up some personal
> information before getting the tutorial.

Google for "Yet Another Haskell Tutorial pdf", and you'll find that
this form can be subverted if you actually care. It also accepts
completely random values.

>
> These are very significant barriers.
>
> Sure, it's not all bad. For example, Haskell has a friendly community
> (low barrier). But the barriers that exist are a problem because they
> hit the person who is trying to take the very very first step. If you
> can make that *fist* step easier, more people will take it.
>
> > The main things is: The ghci prompt accepts either command, starting
> > with a color such as :load "filename" or haskell IO code, since it
> > is in a do-block. Thus let is required.
>
> I understand that the design of Haskell might force this behaviour (I
> don't know, but I guess it must). The best solution I can think of (from
> a usability POV) is to provide a very brief tutorial, just 1/2 page,
> just enough to get someone through "hello world", and put it right at
> the top of the Learning Haskell section. I would remove the Intro
> section (it would fit better on the front page) and replace it with a
> 1/2 page tutorial. Something like this:
>
> -------------// Sugestion -------------
> 40-SECOND INTRO TO HASKELL
>
> (You must have <link>Hugs or GHC installed</link>)
>
> 1. Open a text editor and type:
> fac :: Integer -> Integer
> fac 0 = 1
> fac n | n > 0 = n * fac (n-1)
>
> 2. Save as "fac.hs"
> 3. On a terminal:
>
> $ ghci
> Prelude> :load fac.hs
> Compiling Main             ( fac.hs, interpreted )
> Ok, modules loaded: Main.
> *Main> fac 12
> 479001600
>
> 4. Press Ctrl+D to exit.
>
> For more information, look at the following tutorials:
> -------------// Sugestion -------------
>
> There. That's brief, and it's enough to get the user past the first
> step. It sends the message that Haskell is not so scary.
>
>
> > More typically you would write your code in a file, as shown in:
> > http://www.haskell.org/ghc/docs/6.4.1/html/users_guide/ch03s02.html
>
> Thanks.
>
> Best,
> Daniel.
> --
>       /\/`) http://oooauthors.org
>      /\/_/  http://opendocumentfellowship.org
>     /\/_/
>     \/_/    I am not over-weight, I am under-tall.
>     /
> _______________________________________________
> Haskell-Cafe mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: First steps in Haskell

Wolfgang Jeltsch
In reply to this post by Daniel Carrera-2
Am Sonntag, 18. Dezember 2005 17:25 schrieb Daniel Carrera:
> [...]

> This is a real problem for Haskell. I expect that a lot of people try
> Haskell and give up because they can't even write the simplest function.

Hello Daniel,

honestly, I have to say that during my years with Haskell, this seems to be
the first time that I see somebody trying to enter a Haskell program via the
command line of an interactive environment.  So I suppose that it's not "a
lot of people" who experience the problems you do.

> It's hard not to be put off by this. I love the theory behind Haskell,
> but the practice of it seems to be a real problem.

Did you have a look at the Hugs or GHCi documentation?  I'm very sure, it will
tell you that what you may enter at the command line are (merely) expressions
to evaluate and special commands like :t for displaying the type of an
expression, and that the Haskell declarations (normally) have to be read from
a file.

> I hope someone will show me how to make this program work. Even better,
> I hope someone will fix the compilers and interpreters if they need
> fixing, or fix the documentation if that's what needs fixing.

I suppose that neither the compilers and interpreters nor the documentation
need(s) fixing, although I might be wrong with the documentation.

> Best,
> Daniel.

Best wishes,
Wolfgang
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: First steps in Haskell

Wolfgang Jeltsch
In reply to this post by Daniel Carrera-2
Am Sonntag, 18. Dezember 2005 17:42 schrieb Daniel Carrera:
> Lemmih wrote:
> > GHC is a compiler. If you want to compile to a binary then you must
> > define a function called 'main'. Otherwise just load the file in ghci
> > (`ghci fac.hs`).
>
> I would expect GHC to be able to compile a program with a function that
> is not called 'main'. I wouldn't expect it to print anything when run,
> but I would expect it to compile.

So you want a program that doesn't contain a main variable to be compiled into
an executable which does nothing?  This doesn't seem to make much sense.

In addition, Haskells requirement of a main variable is nothing new.  Take C,
C++, Java, PASCAL.  They all require you to somehow specify a main
program/function/method.

> `ghci fac.hs` doesn't give any errors. I don't understand why loading
> the file like that is ok but typing the entries is not.

Because the interactive environments are about evaluating expressions based on
declarations which were made in Haskell source files, not about creating new
declarations.  Expressions and declarations are just two different things.  I
think, Cale explained why it might be a bad idea to allow entering
declarations at the command line.

> This might be a problem for people exporing the language.

Hmm, don't know.

> Best,
> Daniel.

Best wishes,
Wolfgang
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

RE: First steps in Haskell

Simon Peyton Jones
In reply to this post by Daniel Carrera-2
Daniel is right, by definition.  He is a new user.  He had difficulty.
That much is incontrovertible.

While he may seem unusual, perhaps he is only unusual in that he's told
us about his experience rather than trying Perl instead.  For which,
much thanks, Daniel!

In any case, I think it'd be great if he, or anyone else, started a Wiki
page on "very first steps in Haskell", along the lines he suggests.
Maybe one exists already?  Once it does, it'd be good to point to it
from haskell.org.

Simon

| -----Original Message-----
| From: [hidden email]
[mailto:[hidden email]] On Behalf Of
| Wolfgang Jeltsch
| Sent: 19 December 2005 09:50
| To: [hidden email]
| Subject: Re: [Haskell-cafe] First steps in Haskell
|
| Am Sonntag, 18. Dezember 2005 17:25 schrieb Daniel Carrera:
| > [...]
|
| > This is a real problem for Haskell. I expect that a lot of people
try
| > Haskell and give up because they can't even write the simplest
function.
|
| Hello Daniel,
|
| honestly, I have to say that during my years with Haskell, this seems
to be
| the first time that I see somebody trying to enter a Haskell program
via the
| command line of an interactive environment.  So I suppose that it's
not "a
| lot of people" who experience the problems you do.
|
| > It's hard not to be put off by this. I love the theory behind
Haskell,
| > but the practice of it seems to be a real problem.
|
| Did you have a look at the Hugs or GHCi documentation?  I'm very sure,
it will
| tell you that what you may enter at the command line are (merely)
expressions
| to evaluate and special commands like :t for displaying the type of an
| expression, and that the Haskell declarations (normally) have to be
read from
| a file.
|
| > I hope someone will show me how to make this program work. Even
better,
| > I hope someone will fix the compilers and interpreters if they need
| > fixing, or fix the documentation if that's what needs fixing.
|
| I suppose that neither the compilers and interpreters nor the
documentation
| need(s) fixing, although I might be wrong with the documentation.
|
| > Best,
| > Daniel.
|
| Best wishes,
| Wolfgang
| _______________________________________________
| Haskell-Cafe mailing list
| [hidden email]
| http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: First steps in Haskell

Wolfgang Jeltsch
In reply to this post by Daniel Carrera-2
Am Sonntag, 18. Dezember 2005 18:04 schrieb Daniel Carrera:
> Joel Koerwer wrote:
> > Then after you've played with you creation a bit, check out
> > http://haskell.org/learning.html <http://haskell.org/learning.html>
>
> Thank you. I did find that page, and it was very easy to find.

There's a link on the Haskell Homepage to this page.

> The problem is that the content of that page, and its links, didn't show me
> how to write a Haskell program (like you did).

If you want to know how to feed, for example, Hugs with your Haskell program,
you might have to have a look at some Hugs documentation.  Remember that
different Haskell implementations like Hugs, GHCi etc. may have different
ways of reading Haskell programs.  So it's advisable to have a look at some
documentation which is specifically about the Haskell system you use.

On the "Learning Haskell" page you can click, for example, on the "Hugs" link,
then on "Documentation" and then on "The Hugs 98 User's Guide" or "The Hugs
98 User Manual".

> Best,
> Daniel.

Best wishes,
Wolfgang
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: First steps in Haskell

Daniel Carrera-2
In reply to this post by Wolfgang Jeltsch
Wolfgang Jeltsch wrote:
> honestly, I have to say that during my years with Haskell, this seems to be
> the first time that I see somebody trying to enter a Haskell program via the
> command line of an interactive environment.

Well, I tried all three (Hugs, GHCI, GHC). The problem is that the
tutorials I found didn't tell me how to run a Haskell program once it
was written.

> Did you have a look at the Hugs or GHCi documentation?

I took a look at all the tutorials listed in the "Learn Haskell" page
(the first one asked me for private information!). If those are not the
tutorials that a new user should be reading, then the problem is on the
web page. It should point to the correct tutorials. This is a usability
problem.


> I suppose that neither the compilers and interpreters nor the documentation
> need(s) fixing, although I might be wrong with the documentation.

I'm sure the compilers and interpreters are doing their job. It's the
documentation/usability side. You have to tell users how to run a
program before you show them anything else. Any of the following would
be an apt solution:

1) Update the tutorials linked to tell the user how to run a program.
2) Update the web page to link to the correct tutorial (if that's the
problem).
3) Update the web page to include a brief (1/2) page tutorial explaining
this first step.

You see, as a site visitor, I have to assume that the tutorials you are
giving me are the ones you expect I should read. It is nearly impossible
for a new user to know to read the GHCI tutorial. Not only is it not
listed, but since when do you read the GCC tutorial when you want to get
started with C? You'd expect the GCC tutorial to be relevant when you
want more advanced compile-time options. The GCC tutorial assumes that
you know how to write a C program. It doesn't tell you to put a main()
function. That information is in the "Introduction to C" tutorial.

Best,
Daniel.
--
      /\/`) http://oooauthors.org
     /\/_/  http://opendocumentfellowship.org
    /\/_/
    \/_/    I am not over-weight, I am under-tall.
    /
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: First steps in Haskell

Daniel Carrera-2
In reply to this post by Wolfgang Jeltsch
Wolfgang Jeltsch wrote:
> In addition, Haskells requirement of a main variable is nothing new.

Certainly nothing new. I just wish that the documentation I read had
told me about it.

>>`ghci fac.hs` doesn't give any errors. I don't understand why loading
>>the file like that is ok but typing the entries is not.
>
> Because the interactive environments are about evaluating expressions based on
> declarations which were made in Haskell source files, not about creating new
> declarations.  Expressions and declarations are just two different things.  I
> think, Cale explained why it might be a bad idea to allow entering
> declarations at the command line.

Ok. I think I understand. I'm sure this will make more sense later.


>>This might be a problem for people exporing the language.
>
> Hmm, don't know.

I think that usability is important. I'm a big fan of usability. You
don't want to give artificial barriers to people who are just starting
to explore the language. Those are the people most likely to turn away.
Make the first step as simple as possible. The mini-tutorial I posted to
the list would be enough. It's little more than a paragraph, and it gets
the user past that first step.

Best,
Daniel.
--
      /\/`) http://oooauthors.org
     /\/_/  http://opendocumentfellowship.org
    /\/_/
    \/_/    I am not over-weight, I am under-tall.
    /
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: First steps in Haskell

Daniel Carrera-2
In reply to this post by Wolfgang Jeltsch
Wolfgang Jeltsch wrote:
>>The problem is that the content of that page, and its links, didn't show me
>>how to write a Haskell program (like you did).
>
> If you want to know how to feed, for example, Hugs with your Haskell program,
> you might have to have a look at some Hugs documentation.  Remember that
> different Haskell implementations like Hugs, GHCi etc. may have different
> ways of reading Haskell programs.

"remember"?  This is the first time I hear this, and I'm bewildered. I
expect two C compilers to be able to compile a correct C program.
Certainly a "hello world" program. How is it possible that two Haskell
implementations disagree on how to read a Haskell program? (unless it's
an advanced program with very unique compiler features - which is bad).

> On the "Learning Haskell" page you can click, for example, on the "Hugs" link,
> then on "Documentation" and then on "The Hugs 98 User's Guide" or "The Hugs
> 98 User Manual".

I doubt a lot of people who didn't already know about Haskell would
think to click on the manual for the *compiler* instead of the link that
says "Haskell Tutorial".

Best,
Daniel.
--
      /\/`) http://oooauthors.org
     /\/_/  http://opendocumentfellowship.org
    /\/_/
    \/_/    I am not over-weight, I am under-tall.
    /
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: First steps in Haskell

Wolfgang Jeltsch
In reply to this post by Daniel Carrera-2
Am Sonntag, 18. Dezember 2005 18:02 schrieb Daniel Carrera:
> Chris Kuklewicz wrote:
> > Almost everything is explained under
> >
> > http://www.haskell.org/ghc/docs/6.4.1/html/users_guide/ghci.html
>
> Ok. How would a visitor to the Haskell site find this document?

The point is that the visitor should know that he/she might need a document
about GHCi if he/she wants to use GHCi.  A introductionary document about
Haskell might not explain a specific Haskell system.  If you read a book
which is about C++ in general, it won't tell you how to use the GNU C++
compiler or Microsoft Visual C++.

If you know that you need some GHC(i) documentation, it shouldn't be much of a
problem to find it.  Go to the GHC homepage, click on "Documentation" and you
will find "The User's Guide" whose short description tells you that it covers
GHCi.

> If this is the correct document for a beginner to start with Haskell,
> perhaps the site should be updated to point to it instead of the documents
> it currently points to.

At least, the site currently points to the GHC homepage.

> I find some usability problems in the documentation section.

Which documentation section do you mean?

> Think of usability in terms of barriers. If you have low barriers, a lot of
> people will have enough motivation to cross them and get started with
> Haskell. If the barriers are very high, only the most intent and motivated
> users will get started. Barriers are bad.

Maybe, some barriers could be lowered but I don't think that the barriers are
currently "very high".  What do others think?

> Consider some barriers for a user who wants to learn Haskell:
>
> * There's no way for a new user to figure out how to successfully run
> the simplest Haskell program.

There is!  "The Hugs 98 User's Guide" and "The GHC User's Guide".

> * The first tutorial listed requires the user to give up some personal
> information before getting the tutorial.

That's bad, of course.

> These are very significant barriers.

Concerning the latter one, I agree with you.

> Sure, it's not all bad. For example, Haskell has a friendly community
> (low barrier).

:-)

> But the barriers that exist are a problem because they hit the person who is
> trying to take the very very first step. If you can make that *fist* step
> easier, more people will take it.

What do you mean with "*fist* step"? :-) :-)

> [...]

> Best,
> Daniel.

Best wishes,
Wolfgang
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: First steps in Haskell

Tomasz Zielonka
In reply to this post by Daniel Carrera-2
On Mon, Dec 19, 2005 at 10:14:07AM +0000, Daniel Carrera wrote:

> Wolfgang Jeltsch wrote:
> >If you want to know how to feed, for example, Hugs with your Haskell
> >program, you might have to have a look at some Hugs documentation.  
> >Remember that different Haskell implementations like Hugs, GHCi etc. may
> >have different ways of reading Haskell programs.
>
> "remember"?  This is the first time I hear this, and I'm bewildered. I
> expect two C compilers to be able to compile a correct C program.
> Certainly a "hello world" program. How is it possible that two Haskell
> implementations disagree on how to read a Haskell program? (unless it's
> an advanced program with very unique compiler features - which is bad).

I think what Wolfgang meant was that different Haskell implementations
may have:
- different executable names, so you have to invoke them differently
- different options
- different style of work
etc...

Of course, all of them should accept all Haskell 98 programs.

Best regards
Tomasz

--
I am searching for a programmer who is good at least in some of
[Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
123