Re: [Haskell-cafe] Re: Control.Exception.evaluate - 'correct definition' not so correct

2008-05-08 Thread Abhay Parvate
Thanks both for the the explanation and the link. The wikibook is really growing fast! Abhay On Wed, May 7, 2008 at 5:05 PM, apfelmus [EMAIL PROTECTED] wrote: Abhay Parvate wrote: Just for curiocity, is there a practically useful computation that uses 'seq' in an essential manner, i.e.

Re: [Haskell-cafe] The Monad.Reader (11) - Call for Copy

2008-05-08 Thread Wouter Swierstra
On 7 May 2008, at 19:56, Andrew Coppin wrote: Wouter Swierstra wrote: Please consider writing something for the next issue of The Monad.Reader. You know, I'm actually tempted to do just that... Please do! We've had lots of excellent articles written by people who were just learning

Re : [Haskell-cafe] I am new to haskell

2008-05-08 Thread minh thu
Hi, Personnaly, I started to learn Haskell with A Gentle Introduction and (from what I recall) really enjoyed it. I find The Haskell School of Expression a bit problematic because it interleaves information about the language with (although nice) large running-through-all-the-chapter examples.

Re: [Haskell-cafe] Using Template Haskell to make type-safe database access

2008-05-08 Thread Wouter Swierstra
Hi Mads, Not only pictures, but also code can say more than a thousands words. Therefore, I have been implementing a proof of concept. The code is attached in two files. Nice! I have to admit, it's much nicer than I expected it to be. Just out of curiousity, what happens when you write:

Re: [Haskell-cafe] I am new to haskell

2008-05-08 Thread Ambrish Bhargava
Thanks for this list. On Thu, May 8, 2008 at 12:29 PM, Benjamin L. Russell [EMAIL PROTECTED] wrote: One hint that is not (at least to my knowledge) listed on haskell.org is that, according to at least one user (see The Programmers' Stone » Blog Archive » A First Haskell Experience at

[Haskell-cafe] Random numbers / monads - beginner question

2008-05-08 Thread Madoc
Hello, I am just learning Haskell. Now, I encountered something that I cannot solve by myself. Your advice will be greatly appreciated. Given a list of numbers, I want to modify each of those numbers by adding a random offset. However, each such modified number shall stay within certain

Re: [Haskell-cafe] Random numbers / monads - beginner question

2008-05-08 Thread Claude Heiland-Allen
Madoc wrote: Given a list of numbers, I want to modify each of those numbers by adding a random offset. However, each such modified number shall stay within certain bounds, given by the integers minValue and maxValue. After that, I want to continue computation with the resulting list of type

Re: [Haskell-cafe] help in tree folding

2008-05-08 Thread Brent Yorgey
On Wed, May 7, 2008 at 6:28 AM, patrik osgnach [EMAIL PROTECTED] wrote: Daniel Fischer ha scritto: Am Dienstag, 6. Mai 2008 22:40 schrieb patrik osgnach: Brent Yorgey ha scritto: On Tue, May 6, 2008 at 8:20 AM, patrik osgnach [EMAIL PROTECTED] wrote: Hi. I'm learning haskell but i'm

Re: [Haskell-cafe] Induction (help!)

2008-05-08 Thread Brent Yorgey
On Wed, May 7, 2008 at 8:01 PM, PR Stanley [EMAIL PROTECTED] wrote: So, when you apply the function to the first element in the set - e.g. Zero or Nil in the case of lists - you're actually testing to see the function works. Then in the inductive step you base everything on the assumption that

Re: [Haskell-cafe] Random numbers / monads - beginner question

2008-05-08 Thread Thomas Dinsdale-Young
Madoc wrote: Given a list of numbers, I want to modify each of those numbers by adding a random offset. However, each such modified number shall stay within certain bounds, given by the integers minValue and maxValue. After that, I want to continue computation with the resulting list of type

Re: [Haskell-cafe] Random numbers / monads - beginner question

2008-05-08 Thread Brent Yorgey
2008/5/8 Thomas Dinsdale-Young [EMAIL PROTECTED]: Madoc wrote: Given a list of numbers, I want to modify each of those numbers by adding a random offset. However, each such modified number shall stay within certain bounds, given by the integers minValue and maxValue. After that, I want to

[Haskell-cafe] Re: [Haskell] Re: ANN: Haddock version 2.1.0

2008-05-08 Thread Simon Marlow
David Waern wrote: 2008/5/2 Claus Reinke [EMAIL PROTECTED]: 2008/5/2 Simon Marlow [EMAIL PROTECTED]: David Waern wrote: No it doesn't, but it's on the TODO list. It needs a fix in GHC. By the way, I'm going to experiment with doing the parsing of comments on the Haddock side instead of in

Re: [Haskell-cafe] Random numbers / monads - beginner question

2008-05-08 Thread Henning Thielemann
On Thu, 8 May 2008, Madoc wrote: Given a list of numbers, I want to modify each of those numbers by adding a random offset. However, each such modified number shall stay within certain bounds, given by the integers minValue and maxValue. After that, I want to continue computation with the

[Haskell-cafe] IO Help

2008-05-08 Thread Mark Wallsgrove
Hey, I am studying Haskell as a unit at University. I find the concept and design idea's of Haskell interesting but I am finding my self struggling to understand the relationship between the normal state and IO state of Haskell. This is my situation: I have created 12 functions for a program

Re: [Haskell-cafe] IO Help

2008-05-08 Thread Henning Thielemann
On Thu, 8 May 2008, Mark Wallsgrove wrote: Problem now is reading the data back into the program. When I read the data back into the program it comes as IO [Track]. This is the code I have been using to load the data: loadData :: String - Catalogue loadData fileName = do x - readFile

Re: [Haskell-cafe] IO Help

2008-05-08 Thread Mark Wallsgrove
Thank you very much for your fast response! Ok, that is now changed, but everything else in my program is expecting Catalogue without IO. Is there a way to change IO Catalogue into Catalogue? Henning Thielemann wrote: On Thu, 8 May 2008, Mark Wallsgrove wrote: Problem now is reading the

Re: [Haskell-cafe] IO Help

2008-05-08 Thread Daniel Fischer
Am Donnerstag, 8. Mai 2008 14:59 schrieb Mark Wallsgrove: Thank you very much for your fast response! Ok, that is now changed, but everything else in my program is expecting Catalogue without IO. Is there a way to change IO Catalogue into Catalogue? Not a recommendable way. But there's no

[Haskell-cafe] (no subject)

2008-05-08 Thread u4538637
Hi I have a bit of a dilemma.I have a list of lists, eg, [[1,2,3],[4,5,6],[7,8,9]]. Imagine they represent a grid with 0-2 on the x axis and 0-2 on the y axis, eg, (0,0) is 1, (1,0) is 2, (2,1) is 6, etc and (2,3) is 9. I want to be able to put in the list of lists, and the (x,y) coordinate,

Re: [Haskell-cafe] Random numbers / monads - beginner question

2008-05-08 Thread Sebastian Sylvan
2008/5/8 Madoc [EMAIL PROTECTED]: Hello, I am just learning Haskell. Now, I encountered something that I cannot solve by myself. Your advice will be greatly appreciated. Given a list of numbers, I want to modify each of those numbers by adding a random offset. However, each such modified

Re: [Haskell-cafe] IO Help

2008-05-08 Thread Henning Thielemann
On Thu, 8 May 2008, Mark Wallsgrove wrote: Thank you very much for your fast response! Ok, that is now changed, but everything else in my program is expecting Catalogue without IO. Is there a way to change IO Catalogue into Catalogue? Yes, but you do not want that. You will go on writing

Re: [Haskell-cafe] (no subject)

2008-05-08 Thread Daniel Fischer
Am Donnerstag, 8. Mai 2008 15:36 schrieb [EMAIL PROTECTED]: Hi I have a bit of a dilemma.I have a list of lists, eg, [[1,2,3],[4,5,6],[7,8,9]]. Imagine they represent a grid with 0-2 on the x axis and 0-2 on the y axis, eg, (0,0) is 1, (1,0) is 2, (2,1) is 6, etc and (2,3) is 9. I want to be

[Haskell-cafe] List questions

2008-05-08 Thread Achim Schneider
[EMAIL PROTECTED] wrote: Hi I have a bit of a dilemma.I have a list of lists, eg, [[1,2,3],[4,5,6],[7,8,9]]. Imagine they represent a grid with 0-2 on the x axis and 0-2 on the y axis, eg, (0,0) is 1, (1,0) is 2, (2,1) is 6, etc and (2,3) is 9. I want to be able to put in the list of lists,

Re: [Haskell-cafe] IO Help

2008-05-08 Thread Henning Thielemann
On Thu, 8 May 2008, Mark Wallsgrove wrote: Thank you very much for your fast response! Ok, that is now changed, but everything else in my program is expecting Catalogue without IO. Is there a way to change IO Catalogue into Catalogue? Btw. there was a nice article precisely about the issue

[Haskell-cafe] Thanks for the help! (Random numbers / monads - beginner question)

2008-05-08 Thread Madoc
Thanks for helping me! Your fast and accurate responses helped me to solve this issue. I am not so angry at IO any more. You showed me more than one way in which I can solve the problem. In addition, the answers to the other thread IO Help helped me too. It seems that Mr. Wallsgrove had a very

Re: [Haskell-cafe] IO Help

2008-05-08 Thread Mark Wallsgrove
Was there? I have been google'ing that problem for ages.. Just one more thing. I have to make a menu system where the user chooses what functionality they want. Because you cannot change a value once it is set I have used recursion so that when something changes it then calls the menu back

Re: [Haskell-cafe] IO Help

2008-05-08 Thread Thomas Davie
On 8 May 2008, at 16:31, Mark Wallsgrove wrote: Was there? I have been google'ing that problem for ages.. Just one more thing. I have to make a menu system where the user chooses what functionality they want. Because you cannot change a value once it is set I have used recursion so that

Re: [Haskell-cafe] IO Help

2008-05-08 Thread Mark Wallsgrove
Thank you all for your help, you have been invaluable Thomas Davie wrote: On 8 May 2008, at 16:31, Mark Wallsgrove wrote: Was there? I have been google'ing that problem for ages.. Just one more thing. I have to make a menu system where the user chooses what functionality they want. Because

Re: [Haskell-cafe] I am new to haskell

2008-05-08 Thread Darrin Thompson
On Thu, May 8, 2008 at 2:59 AM, Benjamin L. Russell [EMAIL PROTECTED] wrote: * Kees Doets and Jan van Eijck: The Haskell Road to Logic, Maths and Programming, As someone approaching haskell with very rusty math skills, this book has been invaluable. My haskell skills are (mostly) beyond what

Re: [Haskell-cafe] Using Template Haskell to make type-safe database access

2008-05-08 Thread Mads Lindstrøm
Hi Wouter, Wouter Swierstra wrote: Nice! I have to admit, it's much nicer than I expected it to be. Just out of curiousity, what happens when you write: selectTupleList :: Connection - IO [Integer] instead of selectTupleList :: Connection - IO [(Integer, String, String)] What

[Haskell-cafe] Re: Interesting critique of OCaml

2008-05-08 Thread Chad Scherrer
Don Stewart dons at galois.com writes: [interesting quote...] Which I think really captures the joy of being able to write algebraic and data structure transformations, via rewrite rules, without having to extend the compiler -- all thanks to purity, laziness, and static typing. This makes me

[Haskell-cafe] Re: [Haskell] Re: ANN: Haddock version 2.1.0

2008-05-08 Thread David Waern
2008/5/8 Simon Marlow [EMAIL PROTECTED]: So basically you want to run a lexer over the source again to collect all the comments? Yes. You really want to use GHC's lexer, because otherwise you have to write another lexer. I don't mind writing a lexer that just collects the comments. It

[Haskell-cafe] Re: Interesting critique of OCaml

2008-05-08 Thread Achim Schneider
Chad Scherrer [EMAIL PROTECTED] wrote: Don Stewart dons at galois.com writes: [Stuff where I totally agree] Now, I don't know much about lisp, but aren't code transformations like this the whole point of macros? What makes is difficult to do the same thing in this context? Proof of

Re: [Haskell-cafe] Re: Interesting critique of OCaml

2008-05-08 Thread Andrew Coppin
Achim Schneider wrote: Some years or decades ahead, perhaps Haskell will not be able to avoid being successful anymore, and that is the time where you'll see things that look like Java, feel like Java, work like Java, but still use a Haskell RTS. I'm told they're calling it F#... [No, I

Re: [Haskell-cafe] Re: Interesting critique of OCaml

2008-05-08 Thread Andrew Coppin
Chad Scherrer wrote: PS - the link now gives a 500 server error - did our traffic overwhelm it? Is the cafe the next slashdot? ;) Hell, I can't even get a TCP SYN-ACK packet out of it... :-/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Random numbers / monads - beginner question

2008-05-08 Thread Dan Weston
Henning Thielemann wrote: On Thu, 8 May 2008, Madoc wrote: minValue = 0::Int maxValue = 1000::Int normalize a | a minValue = minValue | a maxValue = maxValue | otherwise = a normalize' = min maxValue . max minValue There is a curiosity here. The functions

Re: [Haskell-cafe] Re: Interesting critique of OCaml

2008-05-08 Thread Donnie Jones
Hello, I pasted a copy of the article below for those that cannot access the site. I would be interested to see an article on Haskell in the same light as this Ocaml article, aka a constructive criticism of Haskell. Enjoy! __ Donnie ### Begin Article ### Why Ocaml

[Haskell-cafe] Workshop on Generic Programming: Call for Papers (co-located w/ ICFP08)

2008-05-08 Thread Matthew Fluet (ICFP Publicity Chair)
CALL FOR PAPERS Workshop on Generic Programming 2008 Victoria, Canada, 20th September 2008 http://www.comlab.ox.ac.uk/ralf.hinze/wgp2008/cfp.{html,pdf,ps,txt} The Workshop on Generic Programming is sponsored by

Re: [Haskell-cafe] The Monad.Reader (11) - Call for Copy

2008-05-08 Thread Andrew Coppin
Wouter Swierstra wrote: On 7 May 2008, at 19:56, Andrew Coppin wrote: Wouter Swierstra wrote: Please consider writing something for the next issue of The Monad.Reader. You know, I'm actually tempted to do just that... Please do! We've had lots of excellent articles written by people who

Re: [Haskell] [Haskell-cafe] Help with polymorphic functions

2008-05-08 Thread Bulat Ziganshin
Hello Wei, Thursday, May 8, 2008, 11:10:08 PM, you wrote: test :: a - Int - a shift is defined as a - Int - a not exactly ;) this type signature is given inside class Bits, where 'a' isn't a free variable (as in standalone signature declaration), but means 'a' from type class header: class

Re: [Haskell] [Haskell-cafe] Help with polymorphic functions

2008-05-08 Thread Reinier Lamers
Op Thursday 08 May 2008 21:10:08 schreef Wei Yuan Cai: shift is defined as a - Int - a It's not. It's defined as (Bits a) = a - Int - a or something along those lines. So there is a restriction that the type a must be a member of the Bits typeclass. Because test is essentially just shift, its

[Haskell-cafe] Re: I am new to haskell

2008-05-08 Thread Bjorn Buckwalter
Ambrish Bhargava bhargava.ambrish at gmail.com writes: Hi All,I am new to Haskell. Can anyone guide me how can I start on it (Like getting binaries, some tutorials)?Thanks in advance.-- Regards,Ambrish Bhargava Ambrish, When I started learning Haskell I had no previous exposure to functional

[Haskell-cafe] Re: I am new to haskell

2008-05-08 Thread Bjorn Buckwalter
Bjorn Buckwalter bjorn.buckwalter at gmail.com writes: I found the Gentle Introduction... mentioned elsewhere in this thread to be not-so-gentle as described on the tutorials wiki page. I'd avoid it unless you're already comfortable with functional programming. Let me modify that statement.

Re: [Haskell-cafe] The Monad.Reader (11) - Call for Copy

2008-05-08 Thread Wouter Swierstra
Without reading through every issue ever published, do you have any specific examples of this that I [or anybody else in cafe] could take a look at? The following two articles spring to mind: * Kenneth Hoste wrote a gtk2hs tutorial, after having just started using it:

Re: [Haskell-cafe] Re: Interesting critique of OCaml

2008-05-08 Thread Darrin Thompson
2008/5/8 Donnie Jones [EMAIL PROTECTED]: I would be interested to see an article on Haskell in the same light as this Ocaml article, aka a constructive criticism of Haskell. http://www.drmaciver.com/2008/02/tell-us-why-your-language-sucks/ -- Darrin

Re: [Haskell-cafe] The Monad.Reader (11) - Call for Copy

2008-05-08 Thread Don Stewart
andrewcoppin: Wouter Swierstra wrote: On 7 May 2008, at 19:56, Andrew Coppin wrote: Wouter Swierstra wrote: Please consider writing something for the next issue of The Monad.Reader. You know, I'm actually tempted to do just that... Please do! We've had lots of excellent articles

Re: [Haskell-cafe] The Monad.Reader (11) - Call for Copy

2008-05-08 Thread Andrew Coppin
Don Stewart wrote: You should read through every issue ever published though -- there's a lot of interesting lessons in TMR for the practical Haskeller. That would be entertaining sometime, but how many issues have ac... oh, wait... this is issue 11? Hmm, I hadn't realised that this

Re: [Haskell-cafe] The Monad.Reader (11) - Call for Copy

2008-05-08 Thread Donnie Jones
Speaking of old Monad.Reader issues... the wiki says, Issues 2 through 5 http://www.haskell.org/tmrwiki/ can be found on the special tmrwiki – they haven't been included here for licensing reasons. I hope to move over most of the content soon. Any chance of those issues being moved over still?

Re: [Haskell-cafe] Induction (help!)

2008-05-08 Thread PR Stanley
You've got the right idea. Paul: At long last! :-) I should point out that it doesn't make sense to say p(Succ n) = Succ(p(n)), p(x) represents some statement that is either true or false, so it doesn't make sense to say Succ(p(n)). . Paul: okay, da capo: We prove/test

[Haskell-cafe] Newbie Question: Using Haskell Functions in a C Program

2008-05-08 Thread Philip Müller
Hi, I'm in the process of writing a C program, but I can't stop thinking about how some functions would be much nicer implemented in Haskell. Is there a way to write some of the functions in Haskell and then use them in my C code via some kind of interface? BTW yes, I have been thinking

Re: [Haskell-cafe] Induction (help!)

2008-05-08 Thread Daniel Fischer
Am Freitag, 9. Mai 2008 00:04 schrieb PR Stanley: You've got the right idea. Paul: At long last! :-) I should point out that it doesn't make sense to say p(Succ n) = Succ(p(n)), p(x) represents some statement that is either true or false, so it doesn't make sense to say

[Haskell-cafe] Re: Newbie Question: Using Haskell Functions in a C Program

2008-05-08 Thread Achim Schneider
Philip Müller [EMAIL PROTECTED] wrote: Is there a way to write some of the functions in Haskell and then use them in my C code via some kind of interface? The beast you are looking for is called the FFI: Foreign Function Interface. C doesn't make IO any easier, though. More verbose and

[Haskell-cafe] Stack vs Heap allocation

2008-05-08 Thread Edsko de Vries
Hi, How can I know whether something will be stack or heap allocated? For example, in the standard example of why foldl (+) 0 will fail to evaluate a long list of integers due to a stack overflow, but foldl' won't, it is pointed out that foldl starts building up unevaluated thunks. So,

Re: [Haskell-cafe] Newbie Question: Using Haskell Functions in a C Program

2008-05-08 Thread Bulat Ziganshin
Hello Philip, Friday, May 9, 2008, 2:17:41 AM, you wrote: Is there a way to write some of the functions in Haskell and then use them in my C code via some kind of interface? http://haskell.org/haskellwiki/IO_inside#Interfacing_with_foreign_evil_.28under_development.29 and then entries 1,6,7

Re: [Haskell-cafe] Newbie Question: Using Haskell Functions in a C Program

2008-05-08 Thread Don Stewart
mail: Is there a way to write some of the functions in Haskell and then use them in my C code via some kind of interface? Using C just for IO is a bit weird -- perhaps you could illustrate the kind of IO you're doing? Learning how to do IO in Haskell is a much safer solution that linking the

Re: [Haskell-cafe] Stack vs Heap allocation

2008-05-08 Thread Derek Elkins
On Thu, 2008-05-08 at 23:29 +0100, Edsko de Vries wrote: Hi, How can I know whether something will be stack or heap allocated? For example, in the standard example of why foldl (+) 0 will fail to evaluate a long list of integers due to a stack overflow, but foldl' won't, it is pointed

Re: [Haskell-cafe] Newbie Question: Using Haskell Functions in a C Program

2008-05-08 Thread Philip Müller
Thanks for all the answers. I'm testing this right now and simples cases work as expected. However from what I've read it seems it'll get ugly once I try to pass a C array to a Haskell function. Well, maybe arrays in C have been ugly before trying to pass them to Haskell functions ;) To

Re: [Haskell-cafe] Induction (help!)

2008-05-08 Thread Ryan Ingram
On 5/8/08, Daniel Fischer [EMAIL PROTECTED] wrote: No. In the induction step, we prove that IF p(j) holds, THEN p(j+1) holds, too. p(j) is the assumption, and we prove that *given that assumption*, p(j+1) follows. Then we have proved (*) p(j) implies p(j+1), for all j. To formalize this,

Re: [Haskell-cafe] Newbie Question: Using Haskell Functions in a C Program

2008-05-08 Thread Don Stewart
mail: Thanks for all the answers. I'm testing this right now and simples cases work as expected. However from what I've read it seems it'll get ugly once I try to pass a C array to a Haskell function. Right, passing arrays back and forth is going to get tiring. Well, maybe arrays in C

Re: [Haskell-cafe] Stack vs Heap allocation

2008-05-08 Thread Albert Y. C. Lai
Edsko de Vries wrote: sum :: Tree - Int sum t = sum' [t] 0 where sum' [] acc = acc sum' (Leaf i : ts) acc = sum' ts $! (i + acc) sum' (Node l r : ts) acc = sum' (l : r : ts) acc Because of $!, you should compare the Leaf case to foldl', not foldl. The Node case can be said to

Re[2]: [Haskell-cafe] Newbie Question: Using Haskell Functions in a C Program

2008-05-08 Thread Bulat Ziganshin
Hello Philip, Friday, May 9, 2008, 3:09:33 AM, you wrote: Thanks for all the answers. I'm testing this right now and simples cases work as expected. However from what I've read it seems it'll get ugly once I try to pass a C array to a Haskell function.

RE: [Haskell-cafe] Interesting critique of OCaml

2008-05-08 Thread Tim Docker
| An interesting critique of OCaml. | | http://enfranchisedmind.com/blog/2008/05/07/why-ocaml-sucks/ Interesting to me is that my pet ocaml peeve is not there: namely the lack of convenient operator overloading. Admittedly I only used ocaml for 6 months, but I never adapted to needing to write

Re: [Haskell-cafe] Interesting critique of OCaml

2008-05-08 Thread Michael Vanier
Actually, it's (+) for ints and (+.) for floats. Which kind of proves your point. Mike Tim Docker wrote: | An interesting critique of OCaml. | | http://enfranchisedmind.com/blog/2008/05/07/why-ocaml-sucks/ Interesting to me is that my pet ocaml peeve is not there: namely the lack of