RE: [Haskell-cafe] +RTS -M800M

2005-12-19 Thread Simon Peyton-Jones

| Is there any chance there is a bug in recent GHCs (or perhaps Linux?)
| affecting this?  I'm fairly sure I've lately seen Haskell programs
| consuming significantly larger amounts of memory than they should be
| allowed to, and I can try to isolate a test case if it is of
| interest.

New bugs are always possible!  And in the last few months, Simon has
been doing fairly major surgery on parts of the runtime system, as part
of getting multiprocessor-GHC to play nicely.  

So if you can find a test case where GHC is generating code that uses a
lot more memory than it used it, it would be very valuable to us.
Thanks!

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


Re: [Haskell-cafe] Using MonadError within other Monads

2005-12-19 Thread Karl Grapone
On 12/19/05, Andrew Pimlott [EMAIL PROTECTED] wrote:
 [It is best to post questions only to haskell-cafe.]

Roger.


 On Mon, Dec 19, 2005 at 03:53:53PM +1300, Karl Grapone wrote:
  I'm having trouble making use of MonadError within another Monad, in
  this case IO.
snip
 Looking at the signature of f,

  f :: IO (Either String String)

 Either String String is just an ordinary value produced in the IO
 monad--the monad structure of IO and Either String are completely
 independent.
snip
 The outer do is a computation in the IO monad, the inner do is a
 computation in the Either String monad, and the net effect is an IO
 computation returning an Either String computation--which is just what
 the type signature says.  I had to change your code in 3 other places to
 make it type-check; hopefully you can now find them. ;-)

No problem, with a little shove in the right direction :).
Not entirely sure why I didn't arrive at it myself.  I'm using StateT
successfully elsewhere and was overeager in using similar methods
which, as you point out below, is a different situation.
I still find monadic signatures a little confusing, I believe ghci
was, at some point, deriving types for f or g that had MonadError in
place of Either String, so I'll have to think carefully about why it
is so different from the ErrorT type you show below.


 When people speak of nesting monads, they often mean using monad
 transformers.  If you were using the ErrorT monad transformers, your
 signature would look like

 f :: ErrorT String IO String

 You might want to try rewriting your code that way, but I would suggest
 making it work with the current type signatures first.

At one point I was playing with types like 'Either String (IO
String)', which to me seems very similar to the ErrorT type. 
Intuitively they don't seem like they'd be correct... I feel like
determining that there is an error involves interaction with the
outside world, consequently the error part should be inside the IO
monad.

Now that you've cleared up the simpler case for me I'll try out the ErrorT case.

Thanks for the help.
Karl
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] First steps in Haskell

2005-12-19 Thread Wolfgang Jeltsch
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
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] First steps in Haskell

2005-12-19 Thread Wolfgang Jeltsch
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
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] First steps in Haskell

2005-12-19 Thread Simon Peyton-Jones
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: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
| Wolfgang Jeltsch
| Sent: 19 December 2005 09:50
| To: haskell-cafe@haskell.org
| 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
| Haskell-Cafe@haskell.org
| http://www.haskell.org/mailman/listinfo/haskell-cafe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] First steps in Haskell

2005-12-19 Thread Wolfgang Jeltsch
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
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] First steps in Haskell

2005-12-19 Thread Daniel Carrera

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
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] First steps in Haskell

2005-12-19 Thread Daniel Carrera

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
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] First steps in Haskell

2005-12-19 Thread Wolfgang Jeltsch
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
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Int vs Integer

2005-12-19 Thread Wolfgang Jeltsch
Am Montag, 19. Dezember 2005 01:10 schrieb Jared Updike:
 Int is for bounded values -2**32 to 2**32 (I think... maybe 2**-31 and
 2**31 or less if it's boxed?) based on the underlying machine
 representation.

Not really true.  As far as I remember, the Haskell Report just says that Int 
covers at least the integers from -2^27 to 2^27 - 1.  The range for Int can 
be higher than the range just given.  For 32-bit machines it will probably be 
-2^31 to 2^31 - 1 but there's no guarantee for that.

 [...]

  Jared.

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


Re: [Haskell-cafe] First steps in Haskell

2005-12-19 Thread Tomasz Zielonka
On Mon, Dec 19, 2005 at 10:14:07AM +, 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
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] First steps in Haskell

2005-12-19 Thread Daniel Carrera

Wolfgang Jeltsch wrote:
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++.


I just Googled for Introduction to C. The first link was:

http://www.le.ac.uk/cc/tutorials/c/

It includes a brief section on both MS Visual C++ and the Unix CC.

Maybe I've just been lucky in reading all the right tutorials until now 
:) but every time I learn a new language, the intro tutorial tells me 
how to get Hello World running. I have never looked for a compiler 
tutorial. I guess that Haskell is unique among interpreted languages in 
that there are two compilers and they work different.


I wouldn't expect a huge and elaborate description of Hugs or GHCI on a 
tutorial. I'd expect a brief If you have Hugs do xyz and if you have 
GHC do abc.


If you know that you need some GHC(i) documentation, it shouldn't be much of a 
problem to find it.


But you see, I didn't. I thought I needed Haskell documentation, so 
that's what I looked for.



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


Yes. I thought it was for the purpose of installing it. Since I 
installed it with 'apt-get install ghc' I didn't think to click there.



I find some usability problems in the documentation section.


Which documentation section do you mean?


The web page titled Learning Haskell.

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


To be fair, the barriers are not as high as they could be. For example, 
the Haskell community is friendly and helpful and that's a low barrier. 
It took no time between my posting a question and getting a good answer. 
So in the end it took me no more than a day to write Hello World.


I do suggest that the Learning Haskell page could be improved with a 
brief (couple of paragraph) tutorial to get someone through Hello world. 
Or perhaps update the tutorials to say that. I wrote a suggestion on 
another post.



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


Okay, I stand corrected. I rephrase the concern as The links that say 
Learn Haskell don't show you how to run a simple Haskell program.



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


:)


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? :-) :-)


Heh... typing accuracy is over-rated.

Cheers,
Daniel.
--
 /\/`) http://oooauthors.org
/\/_/  http://opendocumentfellowship.org
   /\/_/
   \/_/I am not over-weight, I am under-tall.
   /
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] First steps in Haskell

2005-12-19 Thread Daniel Carrera

Tomasz Zielonka wrote:

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.


Ah. Thanks.

Cheers,
Daniel.
--
 /\/`) http://oooauthors.org
/\/_/  http://opendocumentfellowship.org
   /\/_/
   \/_/I am not over-weight, I am under-tall.
   /
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] First steps in Haskell

2005-12-19 Thread Bjorn Lisper
Simon P-J:
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!

Actually, I have sometimes wished that the various interactive Haskell
interfaces had the possibility to enter also declarations interactively, as
Daniel originally asked for. Lisp interpreters often support this to some
extent, so it is not out of line for a newcomer to expect it also for
Haskell. I often use hugs as a calculator, and sometimes it would be very
convenient to be able to make one or a few short declarations while making
some interactive calculations. It can be quite tedious to create and edit a
source code file on the side and then load it, when all you want is a short
declaration or two.  Would it be that complex to have an interactive
interface enter a declarations mode when it sees a declaration coming, and
then let it create, compile and load a temporary module when the declaration
is finished?

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


RE: [Haskell-cafe] First steps in Haskell

2005-12-19 Thread Simon Peyton-Jones
| Actually, I have sometimes wished that the various interactive Haskell
| interfaces had the possibility to enter also declarations interactively

GHCi does.

ghci  let f x = hello
ghci f True
True

But there's no editor -- it's strictly a one-line definition

Simon


| -Original Message-
| From: Bjorn Lisper [mailto:[EMAIL PROTECTED]
| Sent: 19 December 2005 13:06
| To: Simon Peyton-Jones
| Cc: [EMAIL PROTECTED]; haskell-cafe@haskell.org
| Subject: Re: [Haskell-cafe] First steps in Haskell
| 
| Simon P-J:
| 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!
| 
| Actually, I have sometimes wished that the various interactive Haskell
| interfaces had the possibility to enter also declarations interactively, as
| Daniel originally asked for. Lisp interpreters often support this to some
| extent, so it is not out of line for a newcomer to expect it also for
| Haskell. I often use hugs as a calculator, and sometimes it would be very
| convenient to be able to make one or a few short declarations while making
| some interactive calculations. It can be quite tedious to create and edit a
| source code file on the side and then load it, when all you want is a short
| declaration or two.  Would it be that complex to have an interactive
| interface enter a declarations mode when it sees a declaration coming, and
| then let it create, compile and load a temporary module when the declaration
| is finished?
| 
| Björn Lisper
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] First steps in Haskell

2005-12-19 Thread Wolfgang Jeltsch
Am Montag, 19. Dezember 2005 12:13 schrieb Daniel Carrera:
 [...]

 I guess that Haskell is unique among interpreted languages

Haskell is not an interpreted language.  There are Haskell interpreters, 
there are Haskell compilers.

 in that there are two compilers and they work different.

The basic principles of the interactive environments (Hugs and GHCi) are the 
same, and so are the basic principles of the compilers (GHC, nhc98, ...).  Of 
course, they differ in the details.  But so do different C compilers.

 [...]

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

 Heh... typing accuracy is over-rated.

Well, I couldn't resist... ;-)

 Cheers,
 Daniel.

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


Re: [Haskell-cafe] First steps in Haskell

2005-12-19 Thread Bjorn Lisper
Simon:
Me:
| Actually, I have sometimes wished that the various interactive Haskell
| interfaces had the possibility to enter also declarations interactively

GHCi does.

Ah, I see! Does it open a let-environment with a local definition?

ghci  let f x = hello
ghci f True
True

Hmm, an interesting semantics for f given the declaration :-)

But there's no editor -- it's strictly a one-line definition

Which is useful enough in many situations. I'll try it out...

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


[Haskell-cafe] XML Schema for Haskell parsing?

2005-12-19 Thread Dimitry Golubovsky
GCCXML defines some XML schema for the results of a C(++) program
parsing. Does there exist any agreed-upon XML schema to represent the
results of Haskell program parsing?

Thanks.

--
Dimitry Golubovsky

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


[Haskell-cafe] Wiki resources for Re: First steps in Haskell

2005-12-19 Thread Shae Matijs Erisson
Simon Peyton-Jones [EMAIL PROTECTED] writes:

 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.

There's both HaskellNewbie[1] and HaskellDemo[2].
It would be nice if they were linked from the front page of haskell.org.

Has there been any discussion about keeping the haskell.org pages in a darcs
repository for easy local editing?

http://www.haskell.org/hawiki/HaskellNewbie
http://www.haskell.org/hawiki/HaskellDemo
--
Shae Matijs Erisson - http://www.ScannedInAvian.com/ - Sockmonster once said:
You could switch out the unicycles for badgers, and the game would be the same.

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


[Haskell-cafe] comprehension generators from IO [a]'s ?

2005-12-19 Thread Steve Harris
[reposted from haskell mailing list where I got no bites :) ]

Folks,
I'm new to using monads, and I'd like some help improving a function
definition that I wrote and which works, but for which I think there
should be a clearer way to write it.

What I'm after is something like:
 -- (psuedo-code)
 [(b,c,d) |
   b - getDirectoryContents a_dir,
   c - getDirectoryContents (a_dir ++ / ++ b),
   d - getDirectoryContents (a_dir ++ / ++ b ++ / ++ c) ],


ie. where the generators feed from IO actions instead of lists,  but I
gather this comprehension style isn't supported, which is too bad
because it's really easy to read.  (Is this what was meant by monad
comprehensions that I've heard reference to?)

Here's how I actually wrote it, using nested folds:

import System.IO

-- Load directory entries 3 levels deep under a_dir, as list of tuples (b,c,d)

load3DirLevels :: FilePath - IO [(String,String,String)]
 load3DirLevels a_dir =
do
  bs - getDirectoryContents a_dir


 foldM (\tups b - do
   cs - getDirectoryContents (a_dir ++ / ++ b)
   foldM (\tups' c - do
ds - getDirectoryContents (a_dir ++ / ++ b
++ / ++ c)
foldM (\tups'' d - do
 return $ (b, c, d) : tups''
  ) tups' ds
 ) tups cs
) [] bs

This function isn't so clear at a glance, and yet what it's doing
seems like a pretty common thing to want to do:  are there any library
functions for monads (or IO in particular) that make this sort of thing
easier, or should I to try and write my own function?  Looks not too
difficult to write but I think I might miss something important if I didn't ask
first...  How would you do it?

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


Re: [Haskell-cafe] Using MonadError within other Monads

2005-12-19 Thread Andrew Pimlott
On Mon, Dec 19, 2005 at 10:21:36PM +1300, Karl Grapone wrote:
 I still find monadic signatures a little confusing, I believe ghci
 was, at some point, deriving types for f or g that had MonadError in
 place of Either String, so I'll have to think carefully about why it
 is so different from the ErrorT type you show below.

You used throwError, which is a MonadError method, so it's not
surprising to get a message about MonadError.  Regarding ErrorT...

 At one point I was playing with types like 'Either String (IO
 String)', which to me seems very similar to the ErrorT type. 

Actually, your type

IO (Either String String)

is the same as

ErrorT String IO String

except for the newtype wrapper.  The big difference in use is that the
ErrorT String IO Monad instance combines the monad structures of IO
and Either.  So you won't need nested do's, and a few other things will
have to change (and you might have to think a bit about mapErrs).

 Intuitively they don't seem like they'd be correct... I feel like
 determining that there is an error involves interaction with the
 outside world, consequently the error part should be inside the IO
 monad.

You're correct about that--Either String (IO String) is not a monad.

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


[Haskell-cafe] Help with division

2005-12-19 Thread Daniel Carrera

Hello all,

Playing around with Haskell... I'm writing a 'choose' function:
--//--
fac :: Int - Int
fac 0 = 1
fac n = n*fac(n-1)

choose :: Int - Int - Int
choose n k = fac(n) / (fac(k) * fac(n-k))
--//--

I'm having problems with the last line.

--//--
Prelude :l test.hs
Compiling Main ( test.hs, interpreted )

test.hs:13:20:
No instance for (Fractional Int)
  arising from use of `/' at test.hs:13:20
Probable fix: add an instance declaration for (Fractional Int)
In the definition of `choose':
choose n k = (fac (n)) / ((fac (k)) * (fac (n - k)))
Failed, modules loaded: none.
--//--

The problem is that it doesn't like the / sign. For example, if I 
replace the / by * the function is compiled just fine.


Does anyone know what I'm missing?

Cheers,
Daniel.
--
 /\/`) http://oooauthors.org
/\/_/  http://opendocumentfellowship.org
   /\/_/
   \/_/I am not over-weight, I am under-tall.
   /
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] comprehension generators from IO [a]'s ?

2005-12-19 Thread Chris Kuklewicz
Okay...that works.  Sweet.

gdc x = ListT $ getDirectoryContents x

get3levels top = runListT $ do
  b - gdc top
  c - gdc $ top++('/':b)
  d - gdc $ top++('/':b)++('/':c)
  return (b,c,d)

I feel bound to point out http://haskell.org/hawiki/ListTDoneRight which
has more to say about the details of ListT

Andrew Pimlott wrote:
 On Mon, Dec 19, 2005 at 01:42:19PM -0600, Steve Harris wrote:
 
What I'm after is something like:
 -- (psuedo-code)
 [(b,c,d) |
   b - getDirectoryContents a_dir,
   c - getDirectoryContents (a_dir ++ / ++ b),
   d - getDirectoryContents (a_dir ++ / ++ b ++ / ++ c) ],
 
 
 Check out Control.Monad.List.ListT, which combines list non-determinism
 with another monad.  Eg,
 
 ListT (getDirectoryContents a_dir) :: ListT IO FilePath
 
 Andrew
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe
 

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


Re: [Haskell-cafe] First steps in Haskell

2005-12-19 Thread Benjamin Franksen
On Monday 19 December 2005 12:13, Daniel Carrera wrote:
 Wolfgang Jeltsch wrote:
 * 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.

 Okay, I stand corrected. I rephrase the concern as The links that
 say Learn Haskell don't show you how to run a simple Haskell
 program.

Hello,

very interesting exchange, this. It appears you are experiencing some 
(mild) culture shock here. It is typical for people in the Haskell 
community to view things in a rather principled way. A language 
tutorial is supposed to introduce /the language/. If you want to know 
how to compile or execute a Haskell program, well then, look at the 
appropriate tutorial on the /implementation/. At first this may appear 
like deliberately creating hurdles, but it isn't, it's merely the way 
many (though not all) Haskell people tend to think. They take it for 
granted that a new user is at least educated enough to be aware of the 
difference between the language itself, and its concrete implementation 
in the form of an interpretation or a compilation system. , Now 
although it appears you very well know the difference, you just aren't 
used to it being shoved in your face ;-) Well, another quirk is that 
adherence to what is custom (e.g. in other language communities) is not 
viewed as an important value among lambda folks, at least not if 
there is some general guiding principle that stands against it (in this 
case: the language itself is not to be confused with its concrete 
implementation).

Once SPJ famously called it wairing the hair shirt, refering to the 
unusual way in which Haskell evolved in an extremely principled way 
(purely functional, lazy) which, for instance, during the first years 
made programming IO quite a challenge... until monadic IO was invented, 
so we(*) could finally do it *right*.

Although I like this attitude very much in principle (pun intended), I 
can see that for newcomers this /can/ be a hurdle and I would recommend 
to tone it down a bit and compromise where it doesn't really do any 
harm -- such as explaining how to load and execute a Haskell program 
(using Hugs for instance) in a beginner's tutorial on (yes) Haskell The 
Language Itself ;-)

Cheers,
Ben

(*) Figuratively speaking. Personally, I didn't know anything about 
Haskell back then.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Help with division

2005-12-19 Thread Daniel Carrera

Greg Buchholz wrote:
  Integral division is spelled div... 


Thanks, that worked.

The course material on the website uses a /.  See the second link 
from the top, English notes. On page 5, right at the bottom. This course 
material teaches Gofer which it claims is essentially a subset of 
Haskell. I guess that division must be one of the differences between 
Gofer and Haskell.


Cheers,
Daniel.
--
 /\/`) http://oooauthors.org
/\/_/  http://opendocumentfellowship.org
   /\/_/
   \/_/I am not over-weight, I am under-tall.
   /
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Int vs Integer

2005-12-19 Thread Benjamin Franksen
On Monday 19 December 2005 11:26, Wolfgang Jeltsch wrote:
 Am Montag, 19. Dezember 2005 01:10 schrieb Jared Updike:
  Int is for bounded values -2**32 to 2**32 (I think... maybe 2**-31
  and 2**31 or less if it's boxed?) based on the underlying machine
  representation.

 Not really true.  As far as I remember, the Haskell Report just says
 that Int covers at least the integers from -2^27 to 2^27 - 1.  The
 range for Int can be higher than the range just given.  For 32-bit
 machines it will probably be -2^31 to 2^31 - 1 but there's no
 guarantee for that.

http://www.haskell.org/onlinelibrary/basic.html

6.4  Numbers

...
The finite-precision integer type Int covers at least the range [ - 
2^29, 2^29 - 1]. As Int is an instance of the Bounded class, maxBound 
and minBound can be used to determine the exact Int range defined by an 
implementation. ...

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


Re: [Haskell-cafe] comprehension generators from IO [a]'s ?

2005-12-19 Thread Steve Harris
On 12/19/05, Chris Kuklewicz [EMAIL PROTECTED] wrote:
 Okay...that works.  Sweet.

 gdc x = ListT $ getDirectoryContents x

 get3levels top = runListT $ do
   b - gdc top
   c - gdc $ top++('/':b)
   d - gdc $ top++('/':b)++('/':c)
   return (b,c,d)

Yeah, that's awesome: just as readable as the comprehension
psuedo-code if not more-so.  I knew some monad wizards would step out
with something nice.

Thanks for spelling out what Andrew was getting at also, it would have
been lost on me.  I haven't yet ventured into using any monads but IO
yet, maybe ListT would be a good place to start.


 I feel bound to point out http://haskell.org/hawiki/ListTDoneRight which
 has more to say about the details of ListT

OK. Thanks to you both Chris and Andrew.

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


[Haskell-cafe] Re: First steps in Haskell

2005-12-19 Thread Paul Moore
OOn Mon, 19 Dec 2005 10:50:00 +0100, Wolfgang Jeltsch
[EMAIL PROTECTED] wrote:

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.

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.

I sympathise with Daniel's problems. I have hit many of them, as well.
As Daniel said, they are not complete road blocks, merely bumps in
the learning curve.

Part of the problem may be that much of Haskell's tutorial material is
focused on introducing functional programming (which is a new concept
to the target audience), coupled with the fact that IO and imperative
programming is a relatively advanced concept. That means that
writing standalone programs (as well as being somewhat
compiler-dependent in its details) takes a while to be discussed.

Example: main is first mentioned in A Gentle Introduction to Haskell
in chapter 7.1. That's a *lot* of reading before you get to write
Hello, world...

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

I suspect that the reference documentation is fine, and the tutorials
are great, given what they are trying to do. But there is scope for a
very prominent Getting going document. Daniel's 40-second intro to
Haskell looks good. Expand it a little with a few lines showing tow
to build and compile a Hello, world program in GHC and Hugs (with a
disclaimer that the code itself is magic for now, you'll understand
when you read about monads and the IO monad) to help people who need
to get over the but how do I write a *program* hump, and you're
pretty much there.

Paul.

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