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
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
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
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
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
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
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
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
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.
/
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 (-)
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
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
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
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
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 ()
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
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
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
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:
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.
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
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!
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
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.
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
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.
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
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
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
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.
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
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
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
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
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
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
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?
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
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
, 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
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
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
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
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:
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
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
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,
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
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
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
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
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
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
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.
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
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
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
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
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
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
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,
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
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.
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)
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
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
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
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
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.
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,
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
90 matches
Mail list logo