Re: [Haskell-cafe] Re: Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink)

2009-05-05 Thread Daniel Carrera

Chris Forno (jekor) wrote:

The idea is that I spent years studying different languages, generally
with a textbook. The textbooks tend to focus on teaching rules and
grammar, with a little bit of vocabulary and dialog each chapter. I
think the focus should be reversed.


I think it largely depends on the learner. Some people find vocabulary 
easier, or more interesting, others not. I have a hard time learning a 
lot of isolated facts (e.g. vocabulary), but I find it easier and more 
enjoyable to learn a rule that I can apply many times. But I know people 
who are the exact opposite. I wouldn't want to make an absolute rule.


I generally like rules that will save me a lot of memorization. I hate 
rules that force me to memorize a lot. I am not good at memorization.




I consider myself to be a highly logically-oriented
(audio-digital?) learning type, as I expect many programmers are.
However, I still don't remember most grammar lessons. The only way I
successfully became fluent in a language (Esperanto) was through
immersion, and that wouldn't have been possible without a decent
vocabulary to start with.


I totally understand, and I agree. And with only a few exceptions, I 
would say that vocabulary is more useful than grammar (even if I find 
the former harder to learn).


That said, I cause Esperanto as a good example of a language with rules 
that make learning easier. In Esperanto, the ending of a word tells you 
if the word is a noun, a verb, an adjective, a subject, an object, etc. 
Knowing these rules makes it much easier for you to learn Esperanto. 
When I learn a language, I like learning rules that will make language 
learning easier.




That being said, Esperanto, and even Japanese sentence structure perhaps
is not as different as an agglutinative language like German. I'll need
to study it more to find out.


In the specific case of German, word order is a lot more important than 
any other language I know. You can get everything else about grammar 
wrong, but as long as you put the words in the right place people will 
probably understand you. But if you get everything else right, and put 
the words in the wrong place, you won't be understood.





Absolutely. I'm not trying to claim that you only need 1,000 words to
become fluent, like some courses claim.


Ok. I probably misunderstood something.



The idea is that once you can begin to read with a dictionary by your
side you'll begin learning much faster because you can focus on reading
what *you* are interested in rather than some contrived dialog from a
textbook.


In my case, the things I'm interested in are too technical :-(  I've had 
a hard time finding things that are interesting and are simple enough 
for me to read in German. But I'll get better.




So far I've been focusing on Japanese. I only have 15 or so stories
currently. They take a bit of time to create ;) For now, the navigation
is basically to click the Latest Links link in the header bar or in
the Latest Links box.


Ok.

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


Re: [Haskell-cafe] Is Haskell a Good Choice for Web Applications? (ANN: Vocabulink)

2009-05-04 Thread Daniel Carrera

Hi Chris,

Thanks. This should be interesting. I currently work as a web developer 
and I've been wondering how easy or hard it would be to develop web 
applications with Haskell. So I'll be interested in reading our article.


On a separate topic, I also took a glance at vocabulink.com. I'm 
interested in languages (I am fluent in English and Spanish and speak 
advanced German). I will have to disagree a bit with your pedagogy:


1) You say that grammar doesn't matter. Well, for some languages it 
matters more than others. German, for example, has a very particular 
word order that takes some effort to learn, and if you get it wrong 
people really won't understand you. In German it's ok if you conjugate 
wrong, but it's not ok if you put words in the wrong place. Second, some 
people actually enjoy grammar better and find that grammar helps them 
understand the language. I am one of those people. Different people 
learn differently. I learn rules more easily than disconnected words. 
When I learn vocabulary I do better by learning word families, and so 
on. The Germanic languages rely heavily in word derivation (not so much 
English) so that can be important for learners like me.


2) Your analysis of word count is flawed. Sure, most of the words you 
read come from a very small vocabulary set, but most of the *meaning* in 
a sentence comes from the more obscure words. Imagine that you read this 
sentence: In the newspaper I read that the __ said that the 
problem is that the river has too much  .  In this sentence you 
can understand 90% of the words, but you have almost no idea of what's 
happening. What your word count test really shows is that human 
languages have a lot of redundancy. You could omit the word the from 
the above sentence and you would understand it almost as well. The word 
the is common and contains very little information.



That said, do you have any stories in German? I can't figure out where 
to get the stories.


Daniel.

Chris Forno wrote:

I decided to find out for myself. You can find the results at
http://jekor.com/article/is-haskell-a-good-choice-for-web-applications

Included is the source code for the web application powering
http://www.vocabulink.com/

The source is roughly 2,000 lines of Haskell, along with some SQL and
JavaScript. It's written in literate style and includes a 75-page PDF.
It demonstrates and explains how to:

 * use FastCGI to communicate with a web server (nginx in this case)
 * move data to and from a PostgreSQL database (HDBC)
 * authenticate users with cookies
 * interact with users via asynchronous JavaScript and JSON (AJAJ)
 * collect data with HTML forms (formlets)
 * communicate with users via email
 * cache with memcached
 * implement a custom forums system (with threaded comments)

I make no claims that the code is elegant or idiomatic. It is however
real code that's running in the wild. And I hope it's useful to anyone
else considering doing web development in Haskell.

I welcome and encourage your feedback!

___
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] When is it OK to create a new mailing list?

2009-05-04 Thread Daniel Carrera

Duncan Coutts wrote:

I wanted a mailing list for my project WxGeneric and I am wondering when
it is OK to do so? How big must the potential audience be? Is there any
kind of etiquette or guidelines?

...


Yes, I would recommend for smaller project-specific mailing lists that
you take advantage of the community server which is set up for this
purpose. We provide code hosting, project webspace, shell access, trac
instances and mailing lists. You can pick and choose, you don't need to
use all of them.


Would this not fit well in the wxHaskell mailing list? That list is not 
very high traffic and there is an obvious overlap in the target audience.


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


[Haskell-cafe] Haskell vs Clean (speed comparison)

2009-05-03 Thread Daniel Carrera

Hi,

I think the mail server may have been acting up earlier. I sent this to 
Haskell-beginners, but it more properly belongs here.


I found something interesting. General wisdom is that Clean (or OCaml) 
is faster than Haskell. The claim is often followed by a link to the 
Debian shootout. But on closer inspection, I question this conclusion. 
The Debian shoot out actually has four sets of benchmarks:


1) Intel 32-bit one core.
2) Intel 32-bit quad-core.
3) Intel 64-bit one core.
4) Intel 64-bit quad-core.

It turns out that Clean is only faster for (1). For the others, Haskell 
is faster. Here I compare Haskell, Clean, OCaml, Lisp SBCL, C# Mono and 
Fortran because they are all in the same ball mark:


32-bit sing core [1]: Lisp, Fortran, Clean, Haskell, C# Mono.
32-bit quad-core [2]: Haskell, C# Mono, Lisp, Clean, Fortran.
64-bit sing core [3]: Fortran, OCaml, Haskell, Clean, C# Mono, Lisp.
64-bit quad-core [4]: Haskell, OCaml, Lisp, C# Mono, Fortran, Clean.

Notes:

* The order is fast language first.
* There are no results for OCaml for 32-bit.
* Lisp is List SCBL whatever that is.

Tentative conclusions:

1) Haskell makes very good use of multiple cores. It smokes Clean.
2) For single core, they are neck and neck. Whether Clean is faster 
depends non the architecture.



What do you think?

Daniel.

P.S.
[1]http://shootout.alioth.debian.org/u32/benchmark.php?test=alllang=alld=dataghc=onocaml=onsbcl=oncsharp=onifc=onclean=oncalc=calculatebox=1
[2]http://shootout.alioth.debian.org/u32q/benchmark.php?test=alllang=alld=dataghc=onocaml=onsbcl=oncsharp=onifc=onclean=oncalc=calculatebox=1
[3]http://shootout.alioth.debian.org/u64/benchmark.php?test=alllang=alld=dataghc=onocaml=onsbcl=oncsharp=onifc=onclean=oncalc=calculatebox=1
[4]http://shootout.alioth.debian.org/u64q/benchmark.php?test=alllang=alld=dataghc=onocaml=onsbcl=oncsharp=onifc=onclean=oncalc=calculatebox=1

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


Re: [Haskell-cafe] Haskell vs Clean (speed comparison)

2009-05-03 Thread Daniel Carrera

Gwern Branwen wrote:

Perhaps it's just that no one has parallelized the Clean programs?
Haskellers seem to care about the shootout programs much more than
Cleaners do.


I'm not sure about the second comment. I haven't seen the Haskell site 
mention the shootout, whereas web pages about Clean often do. Perhaps 
what happens is that Haskell has a larger community, so there's more 
chance that someone will submit an optimized program.


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


Re: [Haskell-cafe] Haskell vs Clean (speed comparison)

2009-05-03 Thread Daniel Carrera

Bulat Ziganshin wrote:

32-bit sing core [1]: Lisp, Fortran


:)  this test measures speed of some programs, not languages.


I know. But since I know that you know that too, I opted for brevity.

How can we benchmark a programming language?
We can't - we benchmark programming language implementations.

How can we benchmark language implementations?
We can't - we measure particular programs.


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


[Haskell-cafe] data vs type

2006-01-04 Thread Daniel Carrera

Hello all,

I'm trying to figure out how 'data' and 'type'. I haven't read any 
documentation because I can't find any. Could someone point me to a 
document explaining these? I'm happy to RTFM, I just need to know where 
the FM is :)


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] data vs type

2006-01-04 Thread Daniel Carrera

Ketil Malde wrote:

I'm trying to figure out how 'data' and 'type'.


How data and type...what? :-)


oops... work :)


Generally, 'type' introduces type synonyms, i.e. just gives a new name
to an existing type, while 'data' defines new (algebraic) types.

So you can use

   type Name = String


Ah. Thanks.


Did that help?


Yes, a lot. :)

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] data vs type

2006-01-04 Thread Daniel Carrera

Christian Maeder wrote:

http://www.isi.edu/~hdaume/htut/tutorial.pdf

4.5 Data Types 47

8 Advanced Types 103
8.1 Type Synonyms


Thanks!

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


[Haskell-cafe] Haskell vs Clean

2006-01-04 Thread Daniel Carrera

Hi all,

How would you compare Haskell and Clean? It looks like they are both 
pure functional languages with very similar syntax. It also appears that 
Clean is faster than Haskell, it appears to be fairly fast. I'm curious 
to learn about relative advantages and disadvantages of each.


Thanks for the help!

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


[Haskell-cafe] How to print a string (lazily)

2006-01-03 Thread Daniel Carrera

Hello,

I've been studying more Haskell and I've improved a lot. But I just hit 
a small problem. I want to print all the elements of a linst (putStr). 
I'd like to write something like this:


print_list [] = do putStr 
print_list (x:xs) = (do putStr x)  print_list xs

I know this is wrong, but I hope you can see what I'm trying to do.

I know of other ways I could print a list. For example:

print_list xs = do putStr(join xs)
where join [] = 
  join (x:xs) = (show x) ++ \n ++ join xs

But the thing is, I want to write a lazy version of this function. It's 
not that I need such a function, I'm just trying to learn Haskell.


Any suggestions?

Question: What do you call a function that has side-effects? (like 
putStr) I know that function is the wrong term.


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] How to print a string (lazily)

2006-01-03 Thread Daniel Carrera

Sebastian Sylvan wrote:

Others have already replied with a solution, but it looks to me like
what you're missing is how to sequence commands, which is the whole
purpose of the do notation.

print_list [] = return ()
print_list (x:xs) =
  do putStr x
   print_list xs

The do notation is used here to sequence to IO actions (which answers
your second question), first it prints out the first character in the
string, then it calls itself recursively to print the rest of the
list.


Thanks! And yes, I'm just learning how to sequence commands/actions, so 
I know I'm missing a lot.



The empty list shouldn't print an empty string, it should do nothing
(that is, just return IO () because that's the return type of
print_list)


Yeah... I just didn't know how to do nothing with Haskell. 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] How to print a string (lazily)

2006-01-03 Thread Daniel Carrera

Chris Kuklewicz wrote:

What does lazy printing mean?

I assume it means you evaluate the head of the list, print it, then
recursively do this for the tail of the list.  With an infinite list you
will get inifinite output.

I assume it does not mean you evaluate the whole list before printing
anything.  This would prevent infinite lists from producing output.


Yes, that's exactly what I had in mind. I wanted to print [1..] (an 
infinite list) with each number on a different line.


Thanks for the help. Yes, the function works now.


main = do
  let hw = [Hello, ,World,!]
  mapM_ putStr hw
  mapM_ putStrLn hw
  putStr (unlines hw) -- see also: unwords, words, lines
  printList hw


Cool. I didn't know about (un)words and unlines.

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] How to print a string (lazily)

2006-01-03 Thread Daniel Carrera

Neil Mitchell wrote:

All Haskell functions are lazy, hence there is no need to write a
lazy version of your print_list function. I think the function you
probably want is:

putStr (unlines xs)


Hhmm... that does work, and I'm a bit surprised that it does. I guess 
I'm still stuck in the eager computation mindset. I would expect putStr 
to have to wait for the (unlines xs) to be finished before doing any 
printing, but it doesn't.


Some day I'll get the hang of this lazy evaluation thing. :)


The first one has fewer monads, so I prefer it, but take your pick :)


Monads scare me, so I'll pick the first :)  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] Haskell vs OCaml

2005-12-25 Thread Daniel Carrera

Branimir Maksimovic wrote:

Well I want simple loop for(int i =0;i10;++i)doSomething(i);
in haskell that would be
for begin end f | begin /= end = do  {f begin ; for (begin+1) end f}
| otherwise = return ()


How about:

result = [ doSomething(i) | i - [0..9] ]

I guess it depends on what doSomething() does.

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] Haskell vs OCaml

2005-12-24 Thread Daniel Carrera

Tomasz Zielonka wrote:

When it comes to Haskell, speed is mostly an implementation issue.
Of course, there are many problems with making Haskell programs
run fast, but on the other hand there are also many opportunities.
For example recent developments of GHC promise that Haskell will
be one of the best languages to use on SMP / multicore systems.


So we can expect Haskell to get faster as GHC evolves and multicore 
systems becomre more common...



There are many differences (Haskell on the left):
- pure / impure


Let's see if I understand this one. Haskell and OCaml both treat 
functions as first class objects, including the ability to pass 
functions as arguments or return functions. But OCaml allows you to 
change the value of a variable and that's what makes it impure. Yes?


Does this mean that it's harder to prove an OCaml program correct? Or 
that you have to be careful to not accidentally change the value of 
variables?


I've taken a glance at an OCaml tutorial, and the syntax looks a little 
more difficult than Haskell's (e.g. rec for recursive functions).



- pretty / ugly


:-)

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


[Haskell-cafe] Haskell Speed

2005-12-23 Thread Daniel Carrera

Hi all,

I'm taking a look at the Computer Language Shootout Benchmarks.

http://shootout.alioth.debian.org/

It looks like Haskell doesn't do very well. It seems to be near the 
bottom of the pile in most tests. Is this due to the inherent design of 
Haskell or is it merely the fact that GHC is young and hasn't had as 
much time to optimize as other compilers?


For example, another very slow language is Ruby. In Ruby's case, there 
is a design factor that will always make it slow. I wonder if Haskell is 
in a smilar situation.


Yes yes, I know that a high level language trades CPU time by programmer 
time. I'm still interested in the CPU time question though :)


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


[Haskell-cafe] Re: Tutorial uploaded

2005-12-22 Thread Daniel Carrera

S Koray Can wrote:
As a newbie... I agree that a newbie should be able to write this 
fairly early on:


main = do
   x - getLine()
   putStrLn (The answer is  ++ show(fib(read(x



I'd agree for some definition of 'early'. I'll elaborate:

[snip]


The above code snippet contains typeclasses (show, read, monadic IO, 
lists), syntactic sugar (do, -). When you say a 'newbie' should be able 
to write that early on, I'd interpret that as 'a newbie should be able 
to regurgitate this early on'


Well, I'm a newbie, and I wrote it. I have enough understanding to 
generate that code, even if I don't understand it all. This is what I know:


* x is a string, fib wants an int, and read turns a string into a number.
* The answer is  is a string so you need ++. ++ expects a string, and 
show turns a number into a string.


So, yes, I need *basic* knowledge of types (strings vs numbers) and the 
functions that convert from one to the other. But that's it. I don't 
need to know that do and - are syntactics sugar, or what a monad is 
(heck, I don't know those things).


I think that the following is suitable for chapter 1:
--//--
main = do
putStrLn What is your name? 
name - getLine
putStrLn(Hello  ++ name)
--//--

You don't need to learn about monads, or classes or lists for this. Yes, 
not even lists (Use ++ to catenate strings). All you need to know is 
strings, and that name - getLine gets a line from input and puts it 
in 'name'.


I think that this is suitable for chapter 2:
--//--
main = do
putStrLn Please type a word:
word - getLine
putStrLn(This word has  ++ (show( length word)) ++  letters)
--//--

Here you learn about numbers, and converting numbers to strings (show).

And this is for chapter 3:
--//--
main = do
putStrLn Please type a number:
number - getLine
putStrLn (number ++ ! =  ++ (show (fac read(number)))
--//--

Here you learn about converting a string to number. At some point 
between chapters 1 and 3 you'd learn how to write 'fac' (I guess chapter 1).


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] Statements spanning multiple lines?

2005-12-22 Thread Daniel Carrera

J. Garrett Morris wrote:

Indent the second line:

pythagoras n = [(a,b,c) | a -[1..n], b -[1..n], c -[1..n], a = b, b
   c, a*a + b*b == c*c]



Thanks!

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] Statements spanning multiple lines?

2005-12-22 Thread Daniel Carrera

Greg Buchholz wrote:

You might also like to try the slightly more efficient...

pyth n = [(a,b,c) | a - [1..n],  
b - [a..n],   
c - [a+1..n], 
a*a + b*b == c*c ]


Cool. I'm amazed that actually works. I've been writing filters upon 
filters in all my functions because I didn't realize you could write 
things like that.


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] Re: Tutorial uploaded

2005-12-21 Thread Daniel Carrera

Robin Green wrote:
Whilst localising IO to a small part of the program is generally a good 
idea, beginners should not be scared off by the thought that IO in 
Haskell is so hard it has to be covered on page 94. This is not the 
case. It should be introduced on page 1.


As a newbie... I'll agree with Robin. I /did/ think that IO in Haskell 
was probably very difficult because it's covered in page 94. I skimmed 
through YAHT and IO is covered wyyy deep into the document. I 
haven't read that section yet, but there is a lot of content and to me 
it looked like it must be something difficult. I guess/hope that when I 
get around to reading it I'll find out that it's not as scary as it looks.


If people want Haskell to be treated as a practical language, not just 
something for doing academic teaching and research with, it should be 
taught as a practical language - which means that things like IO and 
space/time usage come to the forefront.


Until recently I thought of Haskell as something you would use for 
Calculus and the like. It seemed like a tool for academia. You may be 
interested to know that one of the reasons I started looking at Haskell 
just now was to help a friend understand Calculus (the other reason is 
that Haskell looks very cool).


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


[Haskell-cafe] Functions with side-effects?

2005-12-21 Thread Daniel Carrera

Hi all,

I'm a Haskell newbie and I don't really understand how Haskell deals 
with functions that really must have side-effects. Like a rand() 
function or getLine().


I know this has something to do with monads, but I don't really 
understand monads yet. Is there someone who might explain this in newbie 
terms? I don't need to understand the whole thing, I don't need a rand() 
function right this minute. I just want to understand how Haskell 
separates purely functional code from non-functional code (I understand 
that a rand() function is inevitably not functional code, right?)


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] Re: Tutorial uploaded

2005-12-21 Thread Daniel Carrera

Udo Stenzel wrote:

Strange, I always thought predictable, understandable and above all
correct code would be the primary goal, with small and quick code coming
later.


Depends on what you mean by quick and small. Do you mean that the 
program should execute fast and have a small memmory foot-print? If so, 
I agree. If what you mean is that the programmer should be able to 
finish the project quickly and it shouldn't have too many lines of code, 
then I think those features are important.



To write interactive Haskell code well, you have to understand
higher order functions.


That's scary, that you need advanced knowledge just to do IO.


Unless you want to
teach people to program as they would do in Basic, that is.


I don't know what you mean by that.

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] Re: Tutorial uploaded

2005-12-21 Thread Daniel Carrera

Henning Thielemann wrote:

IO is always complicated:


I have never once thought it was complicated. All I've ever needed are 
print() and readLine() and those shouldn't be complicated IMO. And I 
wouldn't want to wait for page 120 to learn how to do that. My programs 
are not going to be useful if they can't get user input or produce 
output. I don't want to wait for page 120 to write my first useful program.



So I prefer starting a tutorial without IO,
interaction in GHCi and Hugs should be enough for the beginning.


GHCi and Hugs are enough for the /beginning/ yes, but that doesn't mean 
that IO should go on chapter 7. How about putting it in chapter 2?


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] Functions with side-effects?

2005-12-21 Thread Daniel Carrera

Thanks for all the help. I think things are much clearer now. And this bit:


main = do putStrLn Hello, what is your name?
  name - getLine
  putStrLn (Hello,  ++ name ++ !)


Looks quite straight forward.

I just wrote my very first IO program with Haskell:
--//--
main = do
x - getLine
putStrLn( show(length x) )
--//--

That's not so scary. The next thing I need to figure out is how to act 
on the input data itself (not just its length). For example, if I wanted 
a program to output the nth element of the fibonacci sequence:

--//--
$ ./fib 12
144
--//--

My first inclination would be to write it as:
--//--
main = do
x - getLine
putStrLn( show(fib x) )
--//--

Of course that won't work because x is an IO String and 'fib' wants an 
Int. To it looks like I need to do a conversion IO a - b but from 
what Cale said, that's not possible because it would defeat the 
referential transparency of Haskell.


Hmm... there must be a way to solve this problem though...

In any event, thanks for the help. I'm learning :)

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] Re: Tutorial uploaded

2005-12-21 Thread Daniel Carrera

Udo Stenzel wrote:

Unless you want to
teach people to program as they would do in Basic, that is.


I don't know what you mean by that.


You will soon.  Once you get used to composing functions instead of
sequencing actions, you'll appreciate the difference.


Ah.

Yes, I do think I understand the difference (my math background is 
stronger than my programming background).


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] Re: Tutorial uploaded

2005-12-21 Thread Daniel Carrera

Daniel Fischer wrote:
P.S.: In May, there was a 'Daniel Carrera' around, too. Isn't that a strange 
coincidence?


That was myself, using a different email address. I didn't get too far 
with Haskell that time, but I remembered that I liked it, so I'm going 
back to it a bit now. But I'm still a newbie :)  Notice that I was 
already familiar with a few, very basic concepts (what is functional 
programming?)


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] Functions with side-effects?

2005-12-21 Thread Daniel Carrera

Creighton Hogg wrote:
x is a String, getLine has type IO String.  That's what I 
was getting at in one of my last e-mails.


Hmm... let's see if I understand:

* getLine() has type IO String.
* The - will convert an IO String to a plain String
* So if I do  x - getLine() then x has the type String.

So, the - effectively ammounts to an IO a - a conversion.

In another email John Hughes said that one could think of IO a as a 
set of instructins for obtaining a. I guess that means that IO is a sort 
of imperative layer that helps the purely functional code interact with 
the outside world.


So I can have an IO bit (e.g. a do-block) that calls functions (which 
are purely functional code) but I can't have a function that executes 
any IO.


For example, it is not possible to write a function my_read_file that 
could work like this:


my_data = my_read_file(my_file.txt)

Correct? Otherwise this would be a function that is not referentially 
transparent.


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] Re: Tutorial uploaded

2005-12-21 Thread Daniel Carrera

Sebastian Sylvan wrote:

Well, I certainly disagree there.
I'm not advocating going into a full-blown explanation of monads, just
enough to actually be able to write a real stand-alone program after
the first chapter. They only need to know that do-notation is for
sequencing computations, and (-) is for binding a name to the result
of a computation. That's it!


As a newbie... I agree that a newbie should be able to write this fairly 
early on:


main = do
   x - getLine()
   putStrLn (The answer is  ++ show(fib(read(x


Now, you just said do-notation is for sequencing computations. Would 
it be fair to say that do-blocks are imperative blocks in an otherwise 
functional program?



You could spend the next ten chapters with coding examples that are
not very IO-heavy, and lead with a good example of doing as much as
possible in the pure world (as well as pointing out every now and then
whenever a particularly good IO-separtion was achieved - to
emphasize that it's good practice).

When someone who has programmed before learns Haskell and gets the
impression that IO is beeing left for later because it's hard they
might think bah, what a rubbish language, IO in Visual Basic isn't
hard at all!.


I would agree with both paragraphs. Show basic IO and show that there's 
no need for complex IO because all the logic should be functional.


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] Re: Tutorial uploaded

2005-12-21 Thread Daniel Carrera

Sebastian Sylvan wrote:

Beginners know that too. In fact, they often think that practical
applications need far more IO than they really do! So to insinuate
even slightly that Haskell is bad at IO by avoiding it for two
thirds of a book, is really going to inforce the idea that Haskell
isn't a practical language for practical applications.
It's easily remedied by teaching them a little IO up front (to show
them it's not scary), and then leaving it alone for a while, having a
more thorugough treatment of it later on.


You can show them this on the first page:

main = do
x - getLine()
print my_program(x)

And spend the next 200 pages showing them all the nifty things and 
purely functional things that my_program() could do and not mention 
monads until chapter 14.


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


[Haskell-cafe] Problems with square root...

2005-12-21 Thread Daniel Carrera

Hey,

The sqrt function is not doing what I want. This is what I want:

round sqrt(2)

The problem is that sqrt() returns a Floating value and round wants a 
ReacFrac:

--//--
*Main round sqrt(2)
interactive:1:0:
No instances for (RealFrac (a - a), Integral (t - a1))
  arising from use of `round' at interactive:1:0-4
Probable fix:
  add an instance declaration for (RealFrac (a - a), Integral (t 
- a1))

In the definition of `it': it = round sqrt (2)
*Main
--//--

I'm trying to figure out how to turn a Float into a RealFrac so I can 
pass it to 'round'. Any ideas?


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] Problems with square root...

2005-12-21 Thread Daniel Carrera

Daniel Carrera wrote:

Hey,

The sqrt function is not doing what I want. This is what I want:

round sqrt(2)


Sigh... never fails. Spend an hour trying to solve a problem, and a 
minute after you write to the list you find the solution. I need 
brackets around sqrt. I'm surprised though. I don't understand why it 
dosn't work without brackets.


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] Problems with square root...

2005-12-21 Thread Daniel Carrera

Radu Grigore wrote:

I don't understand why it dosn't work without brackets.


Function application is left associative in Haskell.


Ah. I implicitly assumed right-association (it works in Perl ;) )

Thanks.
--
 /\/`) 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] Problems with square root...

2005-12-21 Thread Daniel Carrera

Mark Goldman wrote:

nitpicky detail:

() - Parenthesis
{} - Braces
[] - Brackets

Sorry to be pedantic, but using the wrong terminology confuses me and
I'm sure others as well.


Being pedantic can be fun :)

The Macquarie Dictionary, which is the official dictionary in Australia, 
says that () are brackets. It says that they are also called 
parentheses or a round bracket, if you need to distinguish between 
them and square brackets [], curly brackets {}, or angle brackets , 
and the definition for parenthesis is the upright brackets ().


Also, I believe, UK English (and International English) uses the term 
brackets that way, but I'd have to check online to make sure; I don't 
have a UK dictionary on me right this minute.


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-20 Thread Daniel Carrera

Simon Peyton-Jones wrote:

I'm certain there are hurdles, but I think on the whole they are
there by accident rather than design.


Why certainly. I have never seen any on-line community that had hurdles 
by design. Hurdles are usually due to the fact that the people who 
design the website/community/whatever already know how everything works.


As an example, I also participate in the OpenOffice.org community. The 
website is *impossible* to use. To be able to get anywhere you need to 
already have fairly in-depth knowledge of the structural organization of 
the project. Sure, the site makes perfect sense to those who designed 
it. That's because it's organized in a way that reflects the internal 
bureocracy, not the questions a visitor is likely to have in mind when 
he arrives.



It turns out that there are a couple of introductory Wiki pages already:
http://www.haskell.org/hawiki/HaskellNewbie
http://www.haskell.org/hawiki/HaskellDemo


Thanks!


It'd be great if someone would like to improve them in the light of
this thread.  (Anyone can do this.)


I'll take a look. I'm handy with documentation and usability (though not 
a trained expert in either).


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] Proposal for a first tutorial.

2005-12-20 Thread Daniel Carrera

Hal Daume III wrote:
Daniel -- can you tell me what was missing from YAHT that wasn't 
sufficient for starting to use Haskell?  It was really intended to solve 
these problems, at least partially, so if it's missing out, I'd like to 
fix it!


I haven't read it. I refuse to give out personal information to read a 
tutorial.


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] Proposal for a first tutorial.

2005-12-20 Thread Daniel Carrera

Bayley, Alistair wrote:

From this page

  http://haskell.org/hawiki/LearningHaskell

there's a link to the tutorial
  http://www.isi.edu/~hdaume/htut/tutorial.pdf

which seems to make no informational demands.


I suggest updating this page:

http://www.haskell.org/learning.html

To point to that file.

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


[Haskell-cafe] Prime numbers

2005-12-20 Thread Daniel Carrera

Hello all,

Trying to learn Haskell here... In a Haskell tutorial I found a function 
deciding if a number is prime:

--//--
prime n = not (factors 2 n)

factors m n | m == n = False
| m  n  = divides m n || factors (m+1) n

divides a b = (mod a b == 0)
--//--

Reference:

http://www.cs.chalmers.se/Cs/Grundutb/Kurser/d1pt/d1pta/Function%20Definition%20by%20Cases%20and%20Recursion/sld038.htm

This function seems to produce a wrong result on the number 38466629 
(warning, slow computation). This number is prime but the function says 
that it's not.


How do I know that 38466629 is prime? Beause:

* http://www.rsok.com/~jrm/printprimes.html says that it is.
* I wrote another prime function that says that it is.

This is my function:
--//--
prime 1 = False
prime 2 = True
prime n = filter (divides n) primes == []
  where numbers = [x | x - [2..n-1], x*x = n]
primes  = filter prime numbers

divides a b = (mod a b == 0)
--//--

I can't figure out what's wrong with the first one. Can anyone spot the 
problem? (I'm just curious - trying to learn 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] Prime numbers

2005-12-20 Thread Daniel Carrera

John Peterson wrote:

Add a type signature:

prime :: Integer - Bool

It's defaulting to Int and you're getting overflows


Thanks. Hmm... it's still not working.

Btw, I mis-reported the problem. The offending number is 38466629, which 
is /not/ prime but the sample program reports as prime.


38466629 = 31 * 1240859

The offending program is:
--//--
prime :: Integer - Bool
prime n = not (factors 2 n)

factors :: Integer - Integer - Bool
factors m n | m == n = False
| m  n  = divides m n || factors (m+1) n

divides :: Integer - Integer - Bool
divides a b = (mod a b == 0)
--//--

The math behind the program seems correct... :(

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] Prime numbers

2005-12-20 Thread Daniel Carrera

Jens Fisseler wrote:

What about this: 38466629 = 31 x 1240859


Yes, I wrote backwards. The offending program says that it's prime but 
it's not.


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] Prime numbers

2005-12-20 Thread Daniel Carrera

Robert Dockins wrote:

-divides a b = (mod a b == 0)
+divides a b = (mod b a == 0)


Oh, thanks. My program assumed one way to define 'divides' and the 
example assumed the other.


When I wrote it I was thinking of (divides a) being a function that 
tells me if the input divides 'a'.


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] Prime numbers

2005-12-20 Thread Daniel Carrera

Henning Thielemann wrote:

factors :: Integer - Integer - Bool
factors m n | m == n = False
| m  n  = divides m n || factors (m+1) n



Btw. I find the recursion harder to understand than the explicit
definition:

factors n = any (divides n) [2..(n-1)]


For what it's worth, I also found this function un-intuitive. What I'd 
expect a function called factors to do is exactly what yours does, and 
not what the one in the example does.


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] Re: First steps in Haskell

2005-12-20 Thread Daniel Carrera

Donn Cave wrote:

I understand that interactive mode can be useful, I'm just wondering
whether it belongs with Hello world in the scheme of things, or if
at that first step it would be better to focus on the language.


Let's compare sample instructions:

Interactive mode:
-
1. Write this on a file and save it as prog.hs
   
   fac 0 = 1
   fac n | n  0 = n * fac(n-1)
   
2. Type ghci on a terminal.
3. Load the program with :load prog.hs
4. Type fac 12

Compiled mode:
---
1. Write this on a file and save it as prog.hs
   
   main = print fac 12

   fac 0 = 1
   fac n | n  0 = n * fac(n-1)
   
2. Type ghc prog.hs -o prog on a terminal.
3. Run the program with ./prog


Comparison:
~~~
1. The compiled mode instructions are only 1 step smaller, and that's 
because that step was moved into the program itself. You still need to 
explain that bit.

2. The compiled mode instructions also introduce main and print.


Over-all, I think that the compiled mode instructions are *marginally* 
more complicated. Not enough to choose one over the other. I would 
choose the interactive mode because it is friendlier to experimentation.


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] Re: Tutorial uploaded

2005-12-20 Thread Daniel Carrera

Peter Simons wrote:

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.


I'm scared of monads :)  I really don't know what a monad is. All I know 
is that you need it for IO because IO implies side-effects and I know 
that Monad is a very scary-looking word :)



If we'd have an opaque World type instead of the IO monad,
'putStrLn' would be:

  putStrLn :: String - World - World


That seems less scary.


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


[Haskell-cafe] Re: Haskell-Cafe Digest, Vol 28, Issue 66

2005-12-20 Thread Daniel Carrera

Scherrer, Chad wrote:

Have you used Haskell's infix notation? It can help keep the order
straight for operators like these. You can write

a `mod` b  -- instead of mod a b
a `divides` b -- instead of divides a b.

This can help with readability, too.


No, I haven't. That's neat, very neat. Thanks for the tip.

I just tried it, and all these are valid:

(a `divides`) b
(`divides` b) a

That's neat because then you can make derived functions and compositions 
and all sorts of neat stuff.


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

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


[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] 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


[Haskell-cafe] First steps in Haskell

2005-12-18 Thread Daniel Carrera

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


Re: [Haskell-cafe] First steps in Haskell

2005-12-18 Thread 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.


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


Re: [Haskell-cafe] First steps in Haskell

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


Re: [Haskell-cafe] First steps in Haskell

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


[Haskell-cafe] About print and side-effects

2005-12-18 Thread Daniel Carrera

Hi all,

The recent responses to my first question (thanks guys!) included the 
following bit:


main = print (fact 42)


Now, print is a side-effect. Shouldn't it involve a do-block or a nomad 
or one of those scary things you hear about when learning about side 
effects in functional programs? How come 'print' is allowed to exist 
alone if it's a side-effect?


Thanks for the help.

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] About print and side-effects

2005-12-18 Thread Daniel Carrera

Chris Kuklewicz wrote:

By nomad you seemed to either be ridiculing or misspelling monad.


Misspelling. It's a new word for me. I'm not really sure what it means. 
I expect it'll take me a while to figure it out.


Thank you for the help.

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


[Haskell-cafe] Int vs Integer

2005-12-18 Thread Daniel Carrera

Hello all,

I found a good Haskell tutorial (second link on the Tutorials column) 
(now that I know how to run the programs in it). I have a question. 
What's the difference between the types Int and Integer? Likewise, 
what's the difference between the types Float and Double? Are those just 
synonims?


Thanks for the help.

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-18 Thread Daniel Carrera

Thanks for the info, and the link.

I probably should have guessed the Double vs Float one. I did program in 
C a while ago...


Cheers,
Daniel.

Jared Updike wrote:

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. Integer is unbounded (arbitrary precision, i.e.
7489571948579148758174534 is a valid Integer). Double is for floating
point values corresponding to C doubles, in hardware (on 32 bit
machines, 64 bit entities) and Floats are half that precision, i.e. 32
bits on 32 bit machines, corresponding to C floats.

see  http://www.haskell.org/onlinereport/basic.html#sect6.3 and
http://www.haskell.org/onlinereport/basic.html#sect6.4 for more info.

 Jared.

On 12/18/05, Daniel Carrera [EMAIL PROTECTED] wrote:


Hello all,

I found a good Haskell tutorial (second link on the Tutorials column)
(now that I know how to run the programs in it). I have a question.
What's the difference between the types Int and Integer? Likewise,
what's the difference between the types Float and Double? Are those just
synonims?

Thanks for the help.

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





--
[EMAIL PROTECTED]
http://www.updike.org/~jared/
reverse )-:
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe




--
 /\/`) 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] Python?

2005-05-11 Thread Daniel Carrera
Quinn Dunkan wrote:
Python has first class functions and lexical scoping, and encourages
higher-order functions, though to a much lesser degree than a real
functional language.
I was surprised to hear about first class functions and higher order 
functions. So I googled for a bit, and I found something neat:

---snip---
# Python implementation of Common Lisp's remove_if
def remove_if(predicate, lst):
return [elem for elem in lst if not predicate(elem)]
print remove_if(lambda x:x % 2, [1,2,3,4,5,6,7,8])
---snip---
This is so cool. So there we have a higher order function, passing a 
funtion as an argument, and even lambda notation. Neat.


It is very natural to
write in a somewhat functional style, especially in regards to
sequence processing: higher order functions and listcomps provide the
processing and its built in generators and iterator protocol provide
some of the benefits of laziness.
Hhhmmm.. I guess the above is also an example of that.
[snip: lots of very interesting info I didn't know about]
Thank you for all the information. I learned a lot today. I had no idea 
that Python had these features.

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


Re: [Haskell-cafe] Python?

2005-05-11 Thread Daniel Carrera
Erik de Castro Lopo wrote:
Its good for small scripting tasks. Its good for string processing.
I find the dynamic typing a pain.
What's dynamic typing?
I have a lady friend who wants to learn how to program. I just decided 
to teach her Python for practical reasons:
Its a great first language for people who aren't interested in
making a career of programming.
But I do hesitate. I would like to teach her Haskell because I think 
it's a better language.
Its a better language for people who either have a computer science
background or intend to study computer science. I would not inflict
a language like Haskell on someone who just wants to get the job
done with as little fuss as possible.

Thank you for the info, I really appreciate it. I feel better about 
Python now.


Given my circunstances, do you think that's a reasonable approach for 
teaching her how to program?
Teach her Python. If you try and teach her Haskell she will end up
programming in visual basic :-).
Heh.
Cheers,
Daniel.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] and what about AliceML?

2005-05-11 Thread Daniel Carrera
fred wrote:
As long as this group seems to tolerate What about Haskell and language X?
As an aside...
This group has been extremely tolerant of my newbie questions. I do want 
to say thank-you to everyone who has been explaining things to me. I've 
learned quite a bit about programming languages the last couple of 
weeks. Just as importantly, I understand better why Haskell rocks, and 
when it is appropriate to use.


has anyone had any experience with AliceML? My initial impression is that it
might be a nice tool for teaching fundamental concepts.
I'd be interested to know too.
Cheers,
Daniel.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Python?

2005-05-10 Thread Daniel Carrera
Hello,
This might be a strange question to ask on a Haskell list, but I do want 
to hear your opinions. What do you think of Python?

To explain where this question is comming from:
I have a lady friend who wants to learn how to program. I just decided 
to teach her Python for practical reasons:

1) Python has a nice IDE-ish thing. It's called idle. It includes both 
a shell and an editor. The interface is simple and clear.

2) I can't get Helium to compile (since I can't get ghc to run) on Solaris.
3) Python has some nice introductory documentation. The Haskell 
documentation is more advanced.

4) She's interested in writing an OOo plugin some day. Python can do that.
But I do hesitate. I would like to teach her Haskell because I think 
it's a better language. But I just don't seem to have the tools to teach 
it to a complete beginner (idle, documentation).

So I'm thinking that perhaps I can use Python, but try to teach her 
functional principles, like not changing the value of a variable and not 
letting her functions have side-effects.

Given my circunstances, do you think that's a reasonable approach for 
teaching her how to program?

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


Re: Can't compile GHC

2005-05-09 Thread Daniel Carrera
Andrew Cheadle wrote:
:-p ok,ok, lots of people (but will they really continue to - we
dropped it from our labs long ago). Having said that, how many
people don't have access to a Windoze or Linux
I don't have access to Win or Linux. But that's besides the point. I 
think it's reasonable to expect to compile ghc on a standard unix system.

While this might be true, having a compiler compile itself is massively
important
Having the compiler able to compile itself, yes. Making that the only 
way to compile it, that's another thing.

Daniel.
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Can't compile GHC

2005-05-09 Thread Daniel Carrera
robert dockins wrote:
Perhaps.  Nonetheless it is common practice for compilers to be written 
in the target language and to be compiled via bootstrapping.  Ever take 
a look at the GCC sources?  You guessed it: C.
Please don't confuse the compiler being written in the target language 
with the compiler requiring itself. It should be possible to compile it 
with a compiler for a /different/ language.

You can compile gcc with Sun's CC. You should be able to compile ghc 
with nh98.


If this is the binary you found, it is possible you have an incorrect 
version of GCC.
No, that's not it. I have 2.95
$ gcc --version
2.95.3
Best,
Daniel.
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Can't compile GHC

2005-05-09 Thread Daniel Carrera
Duncan Coutts wrote:
This route is going to be your best bet. Find any binary version of ghc
that works on your Solaris and then from there you've broken the
GHC-GHC dep cycle.
Okay. Is there a version that's more likely to work than others? Or 
should I try them sequentially from most recent, then go backwards?

Best,
Daniel.
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: [Haskell-cafe] Re: Specify array or list size?

2005-05-07 Thread Daniel Carrera
Max Vasin wrote:
But why do you need that? Where do need to make an assumption about the size
of the list? 
I'm implementing the RC4 algorithm, which requires a state array with 
256 elements containing the bytes from 0 to 255. As the algorithm 
progresses, the elements of the array get shuffled around. This is what 
drives the pseudo-random number generator. But the size of the state 
array is always 256.

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


Re: [Haskell-cafe] Specify array or list size?

2005-05-07 Thread Daniel Carrera
Hamilton Richards wrote:
Well, for starters, lists and arrays are two entirely different topics. 
I've noticed that Haskell newbies sometimes confuse them --possibly the 
use of [] in list types and enumerations triggers an unconscious 
association with [] used in conventional languages for array indexing.
I think it's because there's no real reason for someone to think that 
the words list and array might not be synonims. I certainly don't 
seen a linguistic distinction. Either term refers to an ordered 
collection of items.

Suppose that you learn a new computer language, and it happens to assign 
special meanings to the words collection and group. You don't know 
this. So you start talking about groups as you do in every day English 
and people tell you that you're mixing up concepts.

I guess that a more likely example in programming would be a language 
that differentiates between functions, procedures and subroutines.

As for Haskell arrays, I've been programming in Haskell since the early 
1990's, and I've never really needed them. Most Haskell programmers find 
lists much more useful, and you'd probably be better off concentrating 
on lists until you encounter a problem in which arrays are really 
needed.
Arrays have O(1) lookup, and Lists have O(n) lookup. For some purposes, 
arrays might be better. I'm thinking of reimplementing RC4 with arrays 
to see if it makes a differece.

When you do, you'll discover that in Haskell as in most other 
languages, an array's size is not part of its type.
Well... that's not quite what I was looking for. I just wanted to raise 
an error if the array ever has length other than 256. And I don't know 
how to do that on a language that doesn't have side-effects.

It's nice to see you taking up Haskell with such enthusiasm. If you 
agree with many of us that Haskell's one of today's best programming 
programming languages, I hope you'll help spread the word.
:-)
A lot of concepts from Haskell match the way I think about problems. You 
see, my background is in math, not programming. For example, currying 
and higher order functions are essentially new names for things I've 
been doing for years. So after the concept was explained to me, it 
didn't take me that long to get it.

My current impression is that Haskell is great for anyone with good 
mathematics education. But I don't know how it'd fare with other people.

I have a lady friend who wants to learn how to program. She's a 
technical person, but has no math background to speak of. I can't decide 
whether to start with a clear-syntax imperative language (Ruby) or a 
functional language (Haskell). I confess I've been leaning towards Ruby.

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


Re: [Haskell-cafe] Compiling with NHC98

2005-05-07 Thread Daniel Carrera
Marcin 'Qrczak' Kowalczyk wrote:
$ nhc98 prng.hs -o prng
I/O error (user-defined), call to function `userError':
  In file ./RC4.hi:
1:1-1:6 Found _module_ but expected a interface
GHC and NHC confuse each other with prng.hi files they produce and
examine, in incompatible formats.
You can delete them; they are needed to compile other modules which
use that module.
No look, I don't have /any/ .hi files. I don't know what a .hi file is. 
I don't have GHC either, I've never managed to make it compile. I just 
got my very first Haskell compiler (literally 10min ago).

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


Re: [Haskell-cafe] Specify array or list size?

2005-05-07 Thread Daniel Carrera
Antti-Juhani Kaijanaho wrote:
Your mistake is the start talking about groups as you do in every day
English part.
The point I'm trying to make is that you can't necessarily predict that 
a programming language will abscribe special meaning to standard known 
words like group or list. I can very well talk about a list without 
knowing that the members of this list (see?) might have a special 
meaning for that word that I'm not aware of. You can't possibly forsee 
that sort of thing. It is not a mistake to use the word group to mean 
what it means in English, I can't possibly know that an Algebraist has a 
particular definition of group that differs from every-day use.

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


Re: [Haskell-cafe] Compiling with NHC98

2005-05-07 Thread Daniel Carrera
David Menendez wrote:
*.hi files are analogous to C's *.h files, except that the compiler
generates them.
Thanks, I learned something new today.
You mentioned later that you don't have any *.hi files, so I'm guessing
you didn't compile RC4.hs before you compiled prng.hs.
Correct. I didn't know I had to :-)
If I'm right, you need to do something like this first:
$ nhc98 -c RC4.hs
Okay, I did that and I see a .hi file now. Thanks!
Once that step is done, you should be able to compile prng.hs.
Interestingly, I get a different error now:
$ nhc98 prng.hs -o prng
Undefined   first referenced
 symbol in file
FN_RC4_46rand   ./prng.o
ld: fatal: Symbol referencing errors. No output written to prng
collect2: ld returned 1 exit status
Oh well, I'll figure this out later. For now I'll just have everything 
in one big file. At least that compiles cleanly.

Incidentally, if you aren't already familiar with make or some other
build system, I strongly recommend looking into one. Even for a project
with only two files, having a build system keep track of compilation
dependencies makes things a lot less tedious.
Ok. I played with make once upon a time. Thanks for the advice.
Cheers,
Daniel.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Compiling with NHC98

2005-05-07 Thread Daniel Carrera
Cale Gibbard wrote:
Just out of curiosity, what platform are you on? There seem to be
builds of GHC available for most common ones.
Solaris :-(
I hate Solaris. No, I didn't choose it; this is what the school 
provides. But if all goes well, I'll have my very own Ubuntu Linux box 
within a month or so. :-D

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


[Haskell-cafe] Comparison with Clean?

2005-05-04 Thread Daniel Carrera
Hi all,
Anyone here familiar with the Clean programming language?
http://www.cs.ru.nl/~clean/
It looks /very/ similar to Haskell, both in functionality and syntax.
I would be grateful for any sort of comparison. I'm trying to decide 
which language I should try to learn.

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


Re: [Haskell-cafe] Comparison with Clean?

2005-05-04 Thread Daniel Carrera
Hi Jerzy,
Thank you for your thorough response. I will archive it and come back to 
it as a reference. As I learn more about FP features (e.g. Monads) I'll 
be able to get more from your description.

But just a quick note:
4. A general observation about the use of both languages by a beginner who
  wants to learn on examples:
  Haskell disposes of two decent interactive interpreters: Hugs and GHCI
  permitting to test directly small expression, to ask about their types,
  etc. which is often useful for debugging, and for grasping the essentials
  on small exercises.
For me, right now, this makes a world of a difference. I'm experimenting 
with small exercises on Hugs right now.

  It must be admitted though that neither is really an *interactive* 
Yeah, I noticed... ;-)  But I recently learned about a neat workaround:
I have a file called Test.hs and load it with ':l Test'. Then I start 
exprimenting. I make a small change and type ':l Test' again. So it's 
almost interactive, and not excessively akward.

I think I'll learn a bit more using Haskell, and then I'll be in a 
better position to decide where to continue (probably with Haskell at 
first).


Now, for the people who asked those questions. Choose whatever you wish,
if your philosophy is I have no time to learn two languages, only one,
so tell me which one is better, then I have some VERY STRONG statements:
* Whoever says to you H is *better* that C (or vice-versa) is LYING.
:-)
Well, I merely ask for general impressions and go from there.

* If you want to learn FP, you should have a good view on the principal
 paradigms, not on particular syntactic constructs. Then, some knowledge
 of two different languages is more than helpful.
Ok. Good to know.
* Learning of languages is a big adventure and pleasure.
That's why I'm here.  :-)
I have a strong preference for languages with clear, simple models. For 
example, I like C better than C++, and Ruby better than Python. Even if 
something might take fewer lines in C++ than in C, or be faster in 
Python than in Ruby, I like the feeling that I understand what I'm 
doing. And I see elegance in a simple model with few exceptions.


* Here and elsewhere both H and C communities are helpful, people who
 know, answer all questions without pretensions nor suggestions that 
they  are respectful gurus bothered by beginners (which happens too 
often on  other language-oriented newgroups I visit from time to 
time...).
Indeed. I've been pleasantly surprised by how friendly this group has 
been. I've learned a lot already, and now I have a lot of resources to 
continue my exploration of Haskell and FP.

Incidentally, the Ruby community is friendly too. :-)
Cheers,
Daniel.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Speed comparison?

2005-05-04 Thread Daniel Carrera
John Hughes wrote:
Benchmarks give a very one-sided view, ignoring the large effect that 
ease of programming can have on the final system's performance.
Good point. Ease of programming helps you make /correct/ programs 
quicker, and some times allows you to use more advanced algorithms that 
you wouldn't dare try in C++.

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


Re: [Haskell-cafe] Where do you use Haskell?

2005-05-03 Thread Daniel Carrera
Tomasz Zielonka wrote:
In my experience, the amount of IO code in an average Haskell program
is from 1% to 20%, even in applications which have to do a fair amount
of interaction with the outside world (networking, CGI, system utils).
Ok, I can see that. Thanks.
Haskell's IO is not just a mimicry of traditional imperative languages,
it's an EDSL (embedded domain specific language) for doing IO. Because
it's embedded it benefits from all the other features of Haskell, like
first-class functions, higher-order functions, lexical closures, pattern
matching, etc, etc.
I guess this will make more sense to me as I learn more about the 
language. I'm quite new at this.

If you mean that Haskell is rarely applicable, I disagree.
Well... the purpose of asking here is so knowledgeable people can 
correct my errors. :-)

Thank you for the info. I'm learning.
Cheers,
Daniel.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Where do you use Haskell?

2005-05-03 Thread Daniel Carrera
Ben Lippmeier wrote:
You might like to take a deep breath and start with:
Tackling the awkward squad: monadic input/output, concurrency, 
exceptions, and foreign-language calls in Haskell - Simon Peyton Jones

http://research.microsoft.com/Users/simonpj/papers/marktoberdorf/
Ok. And I'll get to learn what monadic IO is... :-)
PS: Keep asking those questions.
:-)
I'm eager to learn.
Cheers,
Daniel.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Speed comparison?

2005-05-03 Thread Daniel Carrera
Hi all,
Thank you for all the information on my previous question. I learned a 
lot, and good pointers to more info.

My next question is about speed. How fast would you consider Haskell? 
(say, for computational work). How would you compare it to C, Python and 
Ruby?

I suggest C, Python and Ruby as a basis of comparison because:
1) C is what I'd use if I wanted something fast.
2) Python or Ruby is what I'd use if I wanted clean code.
I know that Haskell can be compiled, thanks to ghc. Ruby is interpreted 
and I'm pretty sure Python is quasi-interpreted (it's compiled on the 
fly to Java-style bytecode and a VM runs the bytecode). Furthermore, the 
Haskell page says that ghc produces fast programs. So I would guess that 
Haskell is faster than Python, but not as fast as C.

Would that be correct? For computational work (e.g. a simulation, 
factoring primes, whatever) does it approach C speed?

I would be happy to hear a comparison with any other language you find 
interesting.:-) As well as any other information you'd like to share.

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


Re: [Haskell-cafe] Speed comparison?

2005-05-03 Thread Daniel Carrera
Greg Buchholz wrote:
You might find the The Great Computer Language Shootout
informative... 

http://shootout.alioth.debian.org/
Thanks!
That's a great resource. At first glance, Haskell seems to do well over-all.
Cheers,
Daniel.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Haskell vs OCaml

2005-05-03 Thread Daniel Carrera
Hey,
Marcin just mentioned OCaml as another functional programming language I 
should keep in mind.

Can anyone offer an opinion on how Haskell and OCaml compare? Is OCaml 
as easy to learn as Haskell? Does it have much the same virtues?

I'll go take a look at it.
/daniel goes to Google.
Cheers,
Daniel.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell vs OCaml

2005-05-03 Thread Daniel Carrera
Marcin,
Are you sure that OCaml is similar to Haskell? At first glance, it 
doesn't even look functional. It looks like an imperative language.

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


[Haskell-cafe] Here's a curve ball for Haskell.

2005-05-03 Thread Daniel Carrera
Alright, in Haskell there are no side-effects when you call a function 
twice on the same data you get the same result...

I just decided I'll try to write a good pseudo random number generator 
in Haskell :-)

I'm off to class now, but I'll try it tonight.
Cheers,
Daniel.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Array functions?

2005-05-03 Thread Daniel Carrera
Hello,
I hope these don't turn out to be RTFM questions, but I can't find them 
in my FM :-)

1) Is there a function to get the ith element from an array?
2) Is there a function to get the index of an entry in an array?
I've implemented these two functions below:
1)
find 0 (x:xs) = x
find n (x:xs) = find (n-1) xs
2)
index i (x:xs) =
   if i == x
 then 0
 else 1 + index a xs
This was a fun exercise, but I can't shack off the feeling that I just 
re-invented the wheel.

I need these because I want to be able to swap any two elements from an 
array. This is my swap function:

-- swap i j array   =  swaps the ith and jth elements of 'array'.
--
swap i j arr = a_head ++ [item_j] ++ a_midd ++ [item_i] ++ a_tail
   where a_head = [a | a - arr, index a arr   i]
 item_i = find i arr
 a_midd = [a | a - arr,(index a arr   i)  (index a arr  j)]
 item_j = find j arr
 a_tail = [a | a - arr, index a arr   j]
I'm sure this was a poor way to accomplish this, but it was a learning 
experience. If anyone would like to show me a more elegant solution, I 
would be happy to see it.

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


Re: [Haskell-cafe] Array functions?

2005-05-03 Thread Daniel Carrera
Hi Ben,
Take a look at this one:
http://www.haskell.org/onlinelibrary/standard-prelude.html
Thanks.
What's the Prelude ?

1) Is there a function to get the ith element from an array?
From your own implementations I gather you mean 'list', not 'array'.
What's the difference?
Now, if you happen to also want to know these functions for real arrays, not 
lists, I suppose you take a look at the standard library module Array.
Thanks for all the info!
Cheers,
Daniel.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Clarification on proof section of HS: The Craft of FP

2005-05-02 Thread Daniel Carrera
Hi Echo,
I'm totally new at Haskell btw. But I'll comment a bit. :-)
My copy of HS: The Craft Of FP just arrived
Is it good? Do you recommend it? Should I get a copy too?
and I was reading section 8.5 about induction. On page 141, Simon Thompson
gives a method of proving properties of functions on lists:
1) Prove that the property holds for the null list
2) Prove that the property holds for (x:xs) under the assumption
that the property holds for xs.
Cool. Mathematical induction. I can see how that would be a sueful skil 
for an FP programmer.

In other words, how does proof of the property on empty lists and proof
that the property holds on (x:xs) under the assumption that it holds on
xs give proof that it holds on all lists? Isn't there a recursive
dependency here?
I'll offer two explanations. Hopefully one will make sense. :-)
Explanation 1:
Fact (*): You proved P(xs) = P(x:xs).
step 0: prove for the empty list.
step 1: given (*) and step 0, you get the result for a 1-item list.
step 2: given (*) and step 1, you get the result for a 2-item list.
...
step n: given (*) and step n-1, you get the result for a n-item list.
Explanation 2:
Start with any list xs, it can be written in the form (y:ys). So if you 
prove the property for ys you're done, right? Continue this recursively, 
removing one entry on each round. Eventually you'll hit an empty list. 
But you proved the property for the empty. So, recursively, you've 
proven it for all lists.

Hope that helps.
This is called mathematical iduction. It is one of the most popular 
methods of proving theorems in mathematics.

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


Re: [Haskell-cafe] Clarification on proof section of HS: The Craft of FP

2005-05-02 Thread Daniel Carrera
Henning Thielemann wrote:
Well, I also omited the word countable. I figure it's understood 
since computers only deal with finite data. And given an infinite 
list, any finite head of it would meet the criteria, so the 
distinction is moot. Unless Haskell has some neat property I am not 
aware of :-)
If you don't take care you may end up proving that e.g.
  repeat 1 ++ [0]  ==  repeat 0
 because for the first list you can prove that every reachable element 
is equal to its neighbour and the last element is 0.
Note:  I'm totally new at Haskell.
What does ++ do?
What does 'repeat' do?
Cheers,
Daniel.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Where do you use Haskell?

2005-05-02 Thread Daniel Carrera
Hi all,
Again, I'm the new guy slowly learning this fuctional programming 
thing. :-)

I've been reading, and I'm really liking the elgance of Haskell, and FP 
as a whole. But I wonder about the range of applicability. You see, one 
of the things about FP is that there are no side-effects and the same 
function on the same parameters always returns the same value. But any 
program that interacts with the real world cannot meet those properties.

The function ask_user_name() will not return the same value each time. 
If write a chess program, the function get_user_move() will be different 
each time. And every time you update the screen, you're having a 
side-effect.

So, I figure that to do these tasks you heed that do ... - work 
around. But that kills the whole point of using FP in the first place, 
right?

So, I'm tempted to conclude that FP is only applicable to situations 
where user interaction is a small part of the program. For example, for 
simulations.

Now, I'm sure I'm not the first person to have this train of thought. 
And I'm sure there is a good answer why I'm wrong. :-) I'm eager to hear 
what that might be.

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


[Haskell-cafe] Writing functions in Haskell.

2005-04-28 Thread Daniel Carrera
Hello,
I'm trying to get started with Haskell. I must say that as good as the 
language must be, the documentation was been a source of frustration. 
Only one document actually showed me how to get started (ie. run hugs or 
ghci), and I was asked to give out my email address before getting it.

Sigh...
Well, in any event, I did get that document in the end and I've been 
reading through it. I've compiled Hugs on my Solaris workstation. There 
were no errors at compilation. Yet, I think there's something seriously 
wrong with my installation. I can't seem to be able to defin functions:

my/prompt $ hugs

Hugs.Base fibs 1 = 1
ERROR - Syntax error in input (unexpected `=')
And some functions seem to be missing.
Hugs.Base Char.toUpper 'a'
ERROR - Undefined qualified variable Char.toUpper
I was hoping that someone could confirm or deny that my Hugs 
installation is broken.

Thank you for your time.
Cheers,
Daniel.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Writing functions in Haskell.

2005-04-28 Thread Daniel Carrera
Hello Cale,
Thank you for your help.
Cale Gibbard wrote:
From the example you gave, it looks like you're using Yet
Another Haskell Tutorial from http://www.isi.edu/~hdaume/htut/ which
is actually my favourite tutorial.
The tutorial itself is quite good, and I like it. I guess I've had a 
long day, and when I was asked for my name and email I didn't react well.

Oh well, life goes on.

When using hugs or ghci, you should note that what these do is to
evaluate Haskell expressions and print (or execute) the results. To
actually write programs, (define data types and functions and such)
you'll need to fire up a text editor and enter your definitions into a
.hs file, which you can then load with your interpreter by passing the
filename on the commandline, or by using :load filename.hs at the
hugs or ghci prompt. I think this handles your first problem.
Alright, got it. In hinsight, I misunderstood the tutorial. It showed me 
the function but it didn't actually say to type it in. Thanks for the 
help, I can write functions now. :-)


The second problem arises from hugs not doing the same thing as ghci
[snip] You can tell hugs to also load the Char module on top of
whatever code you have loaded by using the command :also Char, after
which the prompt should look like
Char
and you can try
toUpper 'a'
Alright, yes that works. Thanks!

There are a number of resources which you might be interested in for
learning Haskell. You've already found the mailing lists, there is
also an IRC channel: #haskell on irc.freenode.net, where there are
plenty of people to help at any time.
Oh, good. IRC is good.

There's also a wiki at:
http://www.haskell.org/hawiki/FrontPage
The page http://www.haskell.org/hawiki/HaskellNewbie in particular
might be useful, as it answers lots of common questions from new
users. If you have additional questions, feel free to ask them there
and someone will probably respond fairly quickly.
Ok, thanks. I really appreciate the help. And thank you for the friendly 
response. I'm eager to keep learning Haskell. The language looks very 
impressive.

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


Re: [Haskell-cafe] Writing functions in Haskell.

2005-04-28 Thread Daniel Carrera
Alright, I have what I believe must be a simple question. As one of the 
exercises for the Haskell tutorial I got I have to implement an 
alternative to the 'map' function.

This is what I have:
-
my/prompt $ cat Test.hs
module Test
where
my_map p [] = []
my_map p (x:xs) = p x : my_map p xs
my/prompt $ hugs
[snip]
Hugs.Base :l Test
Test :also Char
Char map toUpper Hello
HELLO
Char my_map toUpper Hello
ERROR - Undefined variable my_map
-
I can define other functions now (e.g. Fibonacci, length of a list). So 
I'm not sure why I'm doing wrong here. Even if my syntax is wrong in 
some way, the function should be defined.

I would be grateful if anyone could point out my error.
Cheers,
Daniel.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe