Re: [Haskell-cafe] Really need some help understanding a solution

2009-03-26 Thread David Menendez
2009/3/26 Luke Palmer : > The spine of this trie is maximally lazy: this is key.  If the structure of > the spine depended on the input data (as it does for Data.Map), then we > wouldn't be able to process infinite data, because we can never get it all. > So even making a trie out of the list _|_ g

Re: [Haskell-cafe] Really need some help understanding a solution

2009-03-26 Thread wren ng thornton
Thomas Hartman wrote: Luke, does your explanation to Guenther have anything to do with coinduction? -- the property that a producer gives a little bit of output at each step of recursion, which a consumer can than crunch in a lazy way? It has more to do with "tying the knot" (using laziness to

Re: [Haskell-cafe] Re: Really need some help understanding a solution

2009-03-26 Thread wren ng thornton
Gü?nther Schmidt wrote: The depth this language has is just amazing and the stuff that is tackled in this language is just aaahhh. Can't quite put it in words, maybe something along the lines "the ultimate thing, key to the universe" I don't know. Humbling and frustrating especially when

[Haskell-cafe] Re: about Haskell code written to be "too smart"

2009-03-26 Thread Achim Schneider
wren ng thornton wrote: > Colin Adams wrote: > > 2009/3/25 wren ng thornton : > > when I look up the Haddock-generated documentation for a function, I > > DON'T appreciate it if that is in the form of a hyperlink to a > > research paper. > > And that occurs in several of the libraries shipped wit

Re: [Haskell-cafe] Re: Exception handling in numeric computations

2009-03-26 Thread Jonathan Cast
On Thu, 2009-03-26 at 21:57 -0400, wren ng thornton wrote: > Jonathan Cast wrote: > > Xiao-Yong Jin wrote: > > > > Xiao-Yong Jin wrote: > > > > > So I have another question. Is the following function safe > > > > > and legitimate? > > > > > > > > > >> safeDiv :: (Exception e, Integral a) => > > >

Re: [Haskell-cafe] Re: Exception handling in numeric computations

2009-03-26 Thread wren ng thornton
Jonathan Cast wrote: Xiao-Yong Jin wrote: > > Xiao-Yong Jin wrote: > > > So I have another question. Is the following function safe > > > and legitimate? > > > > > >> safeDiv :: (Exception e, Integral a) => > > >>a -> a -> Either e a > > >> safeDiv x y = unsafePerformIO . try . evalu

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-26 Thread wren ng thornton
Luke Palmer wrote: Alexander Dunlap wrote: > Ultimately, it's not detectable statically, is it? Consider > > import Control.Applicative > > main = do > f <- lines <$> readFile "foobar" > print (head (head f)) > > You can't know whether or not head will crash until runtime. Static checkers are

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-26 Thread wren ng thornton
Alexander Dunlap wrote: wren ng thornton wrote: > Jules Bean wrote: > > head uses "error" in precisely the correct, intended fashion. > > > > head has a precondition (only call on non-empty lists) > > And that is *exactly* my complaint: the precondition is not verified by the > compiler. Therefor

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-26 Thread Luke Palmer
On Thu, Mar 26, 2009 at 6:42 PM, Alexander Dunlap < alexander.dun...@gmail.com> wrote: > On Thu, Mar 26, 2009 at 5:23 PM, wren ng thornton > wrote: > > It's a static error, detectable statically, and yet it's deferred to the > > runtime. I'd much rather the compiler catch my errors than needing t

[Haskell-cafe] Re: mapM as a Space Leak

2009-03-26 Thread Chung-chieh Shan
Thomas Hartman wrote in article <910ddf450903261240p4e4fc8b3pa927fac1b80b2...@mail.gmail.com> in gmane.comp.lang.haskell.cafe: > Well, that's reassuring. > > The reason I asked is that the testp function didn't just show poor > performance. The state monad implementation actually gave a differe

[Haskell-cafe] ANN: FallingBlocks 0.1

2009-03-26 Thread Ben Sanders
Hello, I just uploaded fallingblocks to Hackage. It is another Tetris clone, but it uses SDL, and I thought there could be more SDL examples. Any and all comments and suggestions will be extremely appreciated! There is a darcs repo at http://patch-tag.com/publicrepos/fallingblocks Cheers! -Ben

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-26 Thread Alexander Dunlap
On Thu, Mar 26, 2009 at 5:23 PM, wren ng thornton wrote: > Jules Bean wrote: >> >> wren ng thornton wrote: >> > I have long been disappointed by a number of `error`s which shouldn't > >> > be. For example, the fact that `head` and `div` are not total strikes > me >> > as a (solvable) weakness of t

[Haskell-cafe] Re: about Haskell code written to be "too smart"

2009-03-26 Thread wren ng thornton
John Lato wrote: > From: wren ng thornton > Dan Weston wrote: > > So to be clear with the terminology: > > > > inductive = good consumer? > > coinductive = good producer? > > > > So fusion should be possible (automatically? or do I need a GHC rule?) with > > inductive . coinductive > > > > O

[Haskell-cafe] Re: Really need some help understanding a solution

2009-03-26 Thread Gü?nther Schmidt
Well Folks, I've been programming for almost a decade now and making a living off it for almost 8 years. To me programing in Haskell is sometimes quite a humbling experience, because I come to realize how shallow my ventures so far were. The depth this language has is just amazing and the s

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-26 Thread wren ng thornton
Jules Bean wrote: wren ng thornton wrote: > I have long been disappointed by a number of `error`s which shouldn't > be. For example, the fact that `head` and `div` are not total strikes > me as a (solvable) weakness of type checking, rather than things that > should occur as programmer errors/

Re: [Haskell-cafe] Really need some help understanding a solution

2009-03-26 Thread Thomas Hartman
Re that link: search for wren's comments containing "it is however nicely coinductive" 2009/3/26 Thomas Hartman : > Luke, does your explanation to Guenther have anything to do with > coinduction? -- the property that a producer gives a little bit of > output at each step of recursion, which a cons

Re: [Haskell-cafe] Really need some help understanding a solution

2009-03-26 Thread Thomas Hartman
Luke, does your explanation to Guenther have anything to do with coinduction? -- the property that a producer gives a little bit of output at each step of recursion, which a consumer can than crunch in a lazy way? I find that coinduction seems to figure frequently in algos that process a stream.

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-26 Thread wren ng thornton
Colin Adams wrote: 2009/3/25 wren ng thornton : > > Most of the "documentation" is in research papers, and a "normal" > > programmer don't want to read these papers. > > Yes, and no. There is quite a bit of documentation in research papers, and > mainstream programmers don't read research. Howe

Re: [Haskell-cafe] Grouping - Map / Reduce

2009-03-26 Thread Peter Verswyvelen
I'm also learning Haskell so the solution below might be (1) inefficient and (2) incorrect, but hey, let's give it a try :-) For simplicity, in the testing code, I assume an infinite list of key/value pairs where they keys are of type Char between 'a' and 'z' and the values are Integers (the code a

[Haskell-cafe] Re: Really need some help understanding a solution

2009-03-26 Thread Gü?nther Schmidt
Dear Luke, let me thank you first of all for your response, period, and let me also assure you that your efforts are not (totally) in vain. :) Of course I had all kinds of guesses what sort of dark arts you employed here, mostly really long shots (Memoization, CPS ...). And at the end of th

Re: [Haskell-cafe] an OS-independent executeFile??

2009-03-26 Thread Vasili I. Galchin
;^) On Thu, Mar 26, 2009 at 5:32 PM, Jonathan Cast wrote: > On Thu, 2009-03-26 at 17:27 -0500, Vasili I. Galchin wrote: > > ok .. how about API independent? ;^) > > Last I checked VMS, OS/360 (NB: not dead by a long shot), etc. had APIs > too. > > What you really mean is `does not break when run

Re: [Haskell-cafe] an OS-independent executeFile??

2009-03-26 Thread Jonathan Cast
On Thu, 2009-03-26 at 17:27 -0500, Vasili I. Galchin wrote: > ok .. how about API independent? ;^) Last I checked VMS, OS/360 (NB: not dead by a long shot), etc. had APIs too. What you really mean is `does not break when run against Windows's pseudo-POSIX API despite Microsoft's best efforts' :)

Re: [Haskell-cafe] Language.Haskell.Parser question

2009-03-26 Thread Vasyl Pasternak
Wow, uniplate is the library from my dreams :) I knew there should be easy, elegant and simple solution (I hate brute force, that's why I start using Haskell). Many thanks. 2009/3/26 Neil Mitchell : > Hi > >> f1 = foo 5 >> f2 = foo 8 >> f3 = foo 9 >> >> I want to extract a list [5, 8, 9] (suppo

Re: [Haskell-cafe] an OS-independent executeFile??

2009-03-26 Thread Vasili I. Galchin
ok .. how about API independent? ;^) On Thu, Mar 26, 2009 at 5:14 PM, Jonathan Cast wrote: > On Thu, 2009-03-26 at 17:16 -0500, Vasili I. Galchin wrote: > > Hello, > > > > I have been looking through Hackage and using Hoogle to "fork > > and execute" a program in an OS-independent way, i.e.

Re: [Haskell-cafe] an OS-independent executeFile??

2009-03-26 Thread Jonathan Cast
On Thu, 2009-03-26 at 17:16 -0500, Vasili I. Galchin wrote: > Hello, > > I have been looking through Hackage and using Hoogle to "fork > and execute" a program in an OS-independent way, i.e. neutral from > POSIX and Win32 APIs. Does such a library function exist? System.Process.createProces

[Haskell-cafe] an OS-independent executeFile??

2009-03-26 Thread Vasili I. Galchin
Hello, I have been looking through Hackage and using Hoogle to "fork and execute" a program in an OS-independent way, i.e. neutral from POSIX and Win32 APIs. Does such a library function exist? Regards, Vasili ___ Haskell-Cafe mailing list Haskell

[Haskell-cafe] Re: Grouping - Map / Reduce -> blueprint

2009-03-26 Thread Henning Thielemann
On Thu, 26 Mar 2009, Heinrich Apfelmus wrote: Luke Palmer wrote: Yeah, make a trie. Here's a quick example. Nice! There was a thread about this question a few years ago, with some very interesting developments like the "blueprint technique" by Bertram Felgenhauer. http://thread.gmane.or

[Haskell-cafe] Re: Grouping - Map / Reduce

2009-03-26 Thread Heinrich Apfelmus
Luke Palmer wrote: > On Tue, Mar 24, 2009 at 3:15 PM, Gü?nther Schmidt wrote: > >> Hi, >> >> let say I got an unordered lazy list of key/value pairs like >> >> [('a', 99), ('x', 42), ('a', 33) ... ] >> >> and I need to sum up all the values with the same keys. >> >> So far I wrote a naive implemen

Re: [Haskell-cafe] Compile OpenGL for jhc

2009-03-26 Thread Csaba Hruska
Here is the error message of: cabal --jhc install OpenGL http://pastebin.com/m541052a3 2009/3/26 Thomas DuBuisson > Sorry for the double but I messed up the example. That should have been: > >cabal --jhc install Crypto > > > > On Thu, Mar 26, 2009 at 2:10 PM, Thomas DuBuisson > wrote: > >

Re: [Haskell-cafe] Compile OpenGL for jhc

2009-03-26 Thread Thomas DuBuisson
Sorry for the double but I messed up the example. That should have been: cabal --jhc install Crypto On Thu, Mar 26, 2009 at 2:10 PM, Thomas DuBuisson wrote: > I don't know about OpenGL specifically, but there is the --jhc flag > for cabal-install, ex: > >    cabal --jhc Crypto > > Thomas

Re: [Haskell-cafe] Compile OpenGL for jhc

2009-03-26 Thread Thomas DuBuisson
I don't know about OpenGL specifically, but there is the --jhc flag for cabal-install, ex: cabal --jhc Crypto Thomas 2009/3/26 Csaba Hruska : > Hi! > > As OpenGL haskell binding depends only on base, it would be great to compile > it with jhc. I've tried to do that, but I had some problems w

Re: [Haskell-cafe] Really need some help understanding a solution

2009-03-26 Thread Luke Palmer
On Thu, Mar 26, 2009 at 12:21 PM, GüŸnther Schmidt wrote: > Hi guys, > > I tried for days now to figure out a solution that Luke Palmer has > presented me with, by myself, I'm getting nowhere. Sorry, I meant to respond earlier. They say you don't really understand something until you can explai

Re: [Haskell-cafe] Language.Haskell.Parser question

2009-03-26 Thread Neil Mitchell
> Excellent! > The black magic had me scratching my head until I realized it was broken > magic. :) I should probably rerelease Uniplate so the documentation gets fixed, but its not actually "broken" - although there is no way it does what I intended! vals x = [Val i | i <- universe x] Given the

[Haskell-cafe] Compile OpenGL for jhc

2009-03-26 Thread Csaba Hruska
Hi! As OpenGL haskell binding depends only on base, it would be great to compile it with jhc. I've tried to do that, but I had some problems with preprocessor directives. It would be also great to add jhc support for OpenGL bindings build scripts. Or, it would be better to add jhc support for cab

Re: [Haskell-cafe] Language.Haskell.Parser question

2009-03-26 Thread Neil Mitchell
Hi John, > Actually, looking at the docs for UniplateStr[1], isn't there an error in > the following example statement in the Queries section? > > vals x = [Val i | i <- universe x] > > Shouldn't that be: > vals x = [i | Val i <- universe x] Yep, you are indeed right. I've fixed the examples in t

Re: [Haskell-cafe] Language.Haskell.Parser question

2009-03-26 Thread John Van Enk
Excellent! The black magic had me scratching my head until I realized it was broken magic. :) /jve On Thu, Mar 26, 2009 at 4:23 PM, Neil Mitchell wrote: > Hi John, > > > Actually, looking at the docs for UniplateStr[1], isn't there an error in > > the following example statement in the Queries

[Haskell-cafe] ANN: io-capture-0.2 capturing std(out|err) in IO action

2009-03-26 Thread Yusaku Hashimoto
Hi, I announce the release of io-capture package of version 0.2 io-capture is a Library to capturing stdout and stderr in IO action. It exports a function named `capture', It takes an IO and an String, the action to run and the given whole stdin, and returns whole stdout and stderr in the action

Re: [Haskell-cafe] Language.Haskell.Parser question

2009-03-26 Thread John Van Enk
Actually, looking at the docs for UniplateStr[1], isn't there an error in the following example statement in the Queries section? vals x = [Val i | i <- universe x] Shouldn't that be: vals x = [i | Val i <- universe x] ? /jve 1. http://hackage.haskell.org/packages/archive/uniplate/1.2.0.3/doc

[Haskell-cafe] ANNOUNCE: wxAsteroids 1.0

2009-03-26 Thread Henk-Jan van Tuyl
Your space ship enters an asteroid belt, try to avoid collisions! wxAsteroids is a game demonstrating the wxHaskell GUI. More about this at: http://www.haskell.org/haskellwiki/wxAsteroids -- Met vriendelijke groet, Henk-Jan van Tuyl -- http://functor.bamikanarie.com http://Van.Tuyl.eu/ --

Re: mapM as a Space Leak (Was: [Haskell-cafe] about Haskell code written to be "too smart")

2009-03-26 Thread Thomas Hartman
Well, that's reassuring. The reason I asked is that the testp function didn't just show poor performance. The state monad implementation actually gave a different answer -- nonterminating, where the pattern matching solution terminated. 2009/3/26 Jonathan Cast : > On Thu, 2009-03-26 at 12:29 -070

Re: mapM as a Space Leak (Was: [Haskell-cafe] about Haskell code written to be "too smart")

2009-03-26 Thread Jonathan Cast
On Thu, 2009-03-26 at 12:29 -0700, Thomas Hartman wrote: > > I wonder if JHC > > or some other compiler might work better with these examples? > > Are you saying that different compilers might give different answers? > > Yikes! > > Too clever indeed! No, they might produce code with different p

mapM as a Space Leak (Was: [Haskell-cafe] about Haskell code written to be "too smart")

2009-03-26 Thread roconnor
On Wed, 25 Mar 2009, Thomas Hartman wrote: With the state version, there's a lot of behind-the-scenes magic, and as we've seen, things can go wrong. Also, the issue isn't infinite lists, but lists that are longer than the sum of the partitions provided. The state monad partition version goes eq

Re: mapM as a Space Leak (Was: [Haskell-cafe] about Haskell code written to be "too smart")

2009-03-26 Thread Thomas Hartman
> I wonder if JHC > or some other compiler might work better with these examples? Are you saying that different compilers might give different answers? Yikes! Too clever indeed! 2009/3/26 : > On Wed, 25 Mar 2009, Thomas Hartman wrote: > >> With the state version, there's a lot of behind-the-sc

AW: Exception handling in numeric computations (was Re: [Haskell-cafe]Use unsafePerformIO to catch Exception?)

2009-03-26 Thread Kemps-Benedix Torsten
All this is certainly true. But there is still a valid concern: Numerical tasks often allow to predict whether an error might occur or not. Let's say you know that you have a normal matrix N and want to calculate (1+N*N)^-1. Of course the matrix is invertible and therefore it is reasonable to pr

Re: [Haskell-cafe] Re: Exception handling in numeric computations

2009-03-26 Thread Claus Reinke
safeDiv :: (Exception e, Integral a) => a -> a -> Either e a safeDiv x y = unsafePerformIO . try . evaluate $ div x y I just want to know, from a theoretical point of view, whether this 'safeDiv' in above definition is the same as safeDiv' :: (Exception e, Integral a) =>

Re: [Haskell-cafe] Re: Exception handling in numeric computations

2009-03-26 Thread Jonathan Cast
On Thu, 2009-03-26 at 14:23 -0400, Xiao-Yong Jin wrote: > Henning Thielemann writes: > > > On Thu, 26 Mar 2009, Xiao-Yong Jin wrote: > > > >> So I have another question. Is the following function safe > >> and legitimate? > >> > >>> safeDiv :: (Exception e, Integral a) => > >>>a -> a

Re: [Haskell-cafe] Re: Exception handling in numeric computations

2009-03-26 Thread Xiao-Yong Jin
Henning Thielemann writes: > On Thu, 26 Mar 2009, Xiao-Yong Jin wrote: > >> So I have another question. Is the following function safe >> and legitimate? >> >>> safeDiv :: (Exception e, Integral a) => >>>a -> a -> Either e a >>> safeDiv x y = unsafePerformIO . try . evaluate $ div x

[Haskell-cafe] Really need some help understanding a solution

2009-03-26 Thread GüŸnther Schmidt
Hi guys, I tried for days now to figure out a solution that Luke Palmer has presented me with, by myself, I'm getting nowhere. He has kindly provided me with this code: import Data.Monoid newtype IntTrie a = IntTrie [a] deriving Show singleton :: (Monoid a) => Int -> a -> IntTrie a sing

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-26 Thread Henning Thielemann
On Wed, 25 Mar 2009, wren ng thornton wrote: Extensible exceptions are impressive, but the existence of exceptions outside of type annotations says something about purity. Did I already promote explicit-exceptions package? :-) ___ Haskell-Cafe maili

[Haskell-cafe] Re: Exception handling in numeric computations

2009-03-26 Thread John Lato
> Message: 15 > From: Xiao-Yong Jin > John Lato writes: > > So I have another question.  Is the following function safe > and legitimate? > >> safeDiv :: (Exception e, Integral a) => >>            a -> a -> Either e a >> safeDiv x y = unsafePerformIO . try . evaluate $ div x y > > I believe it sh

Re: [Haskell-cafe] Language.Haskell.Parser question

2009-03-26 Thread minh thu
2009/3/26 Vasyl Pasternak : > Hi, > > I want to parse haskell file to find all calls to function 'foo' and > gathers a create a list of all > argumets, which passed to it. E.g. from the following code: > > f1 = foo 5 > f2 = foo 8 > f3 = foo 9 > >  I want to extract a list [5, 8, 9] (suppouse functi

Re[2]: [Haskell-cafe] g++ std:map vs GHC IntMap

2009-03-26 Thread Bulat Ziganshin
Hello Don, Thursday, March 26, 2009, 8:26:18 PM, you wrote: >>> +RTS -c -F1.1 >> It now requires 386 MB of memory, but is 4.7 times slower. >> >> So, now memory required is about the same as the C++ version, but how >> can I optimize memory usage without having to tweak the garbage >> collect

Re: [Haskell-cafe] g++ std:map vs GHC IntMap

2009-03-26 Thread Don Stewart
manlio_perillo: > Bulat Ziganshin ha scritto: >> Hello Manlio, >> >> Thursday, March 26, 2009, 6:39:12 PM, you wrote: >> >>> The test consists in adding 1000 elements to an empty map. >> >> +RTS -c -F1.1 >> >> then read about garbage collection >> >> > > It now requires 386 MB of memory, but is

Re[2]: [Haskell-cafe] g++ std:map vs GHC IntMap

2009-03-26 Thread Bulat Ziganshin
Hello Manlio, Thursday, March 26, 2009, 8:17:03 PM, you wrote: > So, now memory required is about the same as the C++ version, but how > can I optimize memory usage without having to tweak the garbage collector? C++ doesn't use GC so why you compare? -- Best regards, Bulat

Re: [Haskell-cafe] g++ std:map vs GHC IntMap

2009-03-26 Thread Manlio Perillo
Bulat Ziganshin ha scritto: Hello Manlio, Thursday, March 26, 2009, 6:39:12 PM, you wrote: The test consists in adding 1000 elements to an empty map. +RTS -c -F1.1 then read about garbage collection It now requires 386 MB of memory, but is 4.7 times slower. So, now memory required

Re: [Haskell-cafe] Language.Haskell.Parser question

2009-03-26 Thread Neil Mitchell
Hi > f1 = foo 5 > f2 = foo 8 > f3 = foo 9 > >  I want to extract a list [5, 8, 9] (suppouse function takes only one > argument) Firstly, use haskell-src-exts and Language.Haskell.Exts - its a much better library, deals with many extensions, and gives you everything Language.Haskell did. > parse

Re: [Haskell-cafe] g++ std:map vs GHC IntMap

2009-03-26 Thread Manlio Perillo
Brandon S. Allbery KF8NH ha scritto: On 2009 Mar 26, at 11:39, Manlio Perillo wrote: The execution time and CPU usage is almost the same. However the C++ version requires 305 MB, the GHC version 617 MB. I wonder how much of that is due to lifting (i.e. laziness). http://hpaste.org/fastcgi/h

[Haskell-cafe] Language.Haskell.Parser question

2009-03-26 Thread Vasyl Pasternak
Hi, I want to parse haskell file to find all calls to function 'foo' and gathers a create a list of all argumets, which passed to it. E.g. from the following code: f1 = foo 5 f2 = foo 8 f3 = foo 9 I want to extract a list [5, 8, 9] (suppouse function takes only one argument) The most obvious w

Re: [Haskell-cafe] g++ std:map vs GHC IntMap

2009-03-26 Thread Bulat Ziganshin
Hello Manlio, Thursday, March 26, 2009, 6:39:12 PM, you wrote: > The test consists in adding 1000 elements to an empty map. +RTS -c -F1.1 then read about garbage collection -- Best regards, Bulatmailto:bulat.zigans...@gmail.com __

Re: [Haskell-cafe] g++ std:map vs GHC IntMap

2009-03-26 Thread Brandon S. Allbery KF8NH
On 2009 Mar 26, at 11:39, Manlio Perillo wrote: The execution time and CPU usage is almost the same. However the C++ version requires 305 MB, the GHC version 617 MB. I wonder how much of that is due to lifting (i.e. laziness). -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@k

Re: [Haskell-cafe] Copying data files when installing, using Cabal

2009-03-26 Thread Neil Mitchell
Hi Henk-Jan, It works for me, see for example HLint: http://community.haskell.org/~ndm/darcs/hlint And a blog I wrote on it: http://neilmitchell.blogspot.com/2008/02/adding-data-files-using-cabal.html The data files are copied in to the data directory upon install. The data-files: bit must be ne

[Haskell-cafe] Copying data files when installing, using Cabal

2009-03-26 Thread Henk-Jan van Tuyl
L.S., I am trying to install an application with data files (I am developing that application). These data files are mentioned in the .cabal file, after the "Data-files:" keyword. When I give command "runhaskell setup install", the data files are not copied; how can I correct this? -- Re

Re: [Haskell-cafe] Re: Exception handling in numeric computations

2009-03-26 Thread Henning Thielemann
On Thu, 26 Mar 2009, Xiao-Yong Jin wrote: So I have another question. Is the following function safe and legitimate? safeDiv :: (Exception e, Integral a) => a -> a -> Either e a safeDiv x y = unsafePerformIO . try . evaluate $ div x y I believe it should be okay to use this 'saf

Re: [Haskell-cafe] Re: Exception handling in numeric computations

2009-03-26 Thread Xiao-Yong Jin
John Lato writes: > Even in Haskell this separation isn't absolute. Programmer errors, > such as dividing by 0, can and do lead to exceptional conditions. The > proper way to handle dividing by 0 is to not do it in the first place, > but if it happens because of a programming error, you've got

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-26 Thread Manlio Perillo
Claus Reinke ha scritto: Continuing our adventures into stylistic and semantic differences:-) Can you write this analysis on the wiki? Thanks! Manlio ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/has

[Haskell-cafe] g++ std:map vs GHC IntMap

2009-03-26 Thread Manlio Perillo
Hi. I have tried to compare performance of the g++ std::map versus the GHC IntMap. The test consists in adding 1000 elements to an empty map. Haskell code is here: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2899 C++ code is here: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2900 Th

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-26 Thread Lutz Donnerhacke
* Claus Reinke wrote: > Continuing our adventures into stylistic and semantic differences:-) It's good practice to keep a simple minded version of the code and using quickcheck to try to find differences between the optimized and trivial version. It's good practice to even check, that the optimize

Re: [Haskell-cafe] [ANN] I/O library for Windows

2009-03-26 Thread Felix Martini
> As I understand it, programs compiled with GHC currently use MSYS for all > I/O operations, resulting in all kinds of strange behaviour in corner cases. > (E.g., if you use System.Directory and ask whether "C:\\" is a directory, it > says no, yet you can read the contents of that directory.) I wo

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-26 Thread Henning Thielemann
On Thu, 26 Mar 2009, Jules Bean wrote: There are programming styles which avoid using 'head'. You are free to use those if you don't like it. I myself am content to use 'head' on lists which I know are guaranteed to be non-empty. Since I became aware that viewl (Data.Sequence) and uncons (By

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-26 Thread Claus Reinke
Continuing our adventures into stylistic and semantic differences:-) Comparing the 'State' and explicit recursion versions takeListSt = evalState . mapM (State . splitAt) -- ..with a derivation leading to.. takeListSt []s = [] takeListSt (h:t) s = x : takeListSt t s' where

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-26 Thread Jules Bean
wren ng thornton wrote: I have long been disappointed by a number of `error`s which shouldn't be. For example, the fact that `head` and `div` are not total strikes me as a (solvable) weakness of type checking, rather than things that should occur as programmer errors/exceptions at runtime. The

Re: [Haskell-cafe] Re: Exception handling in numeric computations

2009-03-26 Thread John Lato
On Wed, Mar 25, 2009 at 7:02 PM, Gregory Petrosyan wrote: > First of all, thanks everybody for the discussion -- very interesting to read! > > Apologies if this is off-topic a bit. > > While reading, I have a feeling that proposed solutions are somewhat similar > to checked exceptions. And IMO the

[Haskell-cafe] Re: about Haskell code written to be "too smart"

2009-03-26 Thread John Lato
> From: wren ng thornton > Dan Weston wrote: >> So to be clear with the terminology: >> >> inductive   = good consumer? >> coinductive = good producer? >> >> So fusion should be possible (automatically? or do I need a GHC rule?) with >>   inductive . coinductive >> >> Or have I bungled it? > > Not

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-26 Thread Loup Vaillant
2009/3/26 Thomas Hartman : >> Beginner list processing code can and often does go awry when presented with >> infinite lists. > > I didn't mean code that a beginner would write, I mean code that would > be easy to understand for a beginner to read For that, in this particular example, a type sign

Fwd: [Haskell-cafe] Re: ANNOUNCE: WinGhci, a GUI for GHCI on Windows

2009-03-26 Thread Pepe Gallardo
2009/3/23 Andrew Butterfield > Benjamin L.Russell wrote: > >> This is wonderful--just what I was waiting for! The application looks >> beautiful, and I'm very happy that GHCi now has a matching GUI >> application along the lines of WinHugs. >> >> > Indeed - me too ! > >> It would be even better

Fwd: [Haskell-cafe] Re: ANNOUNCE: WinGhci, a GUI for GHCI on Windows

2009-03-26 Thread Pepe Gallardo
-- Forwarded message -- From: Pepe Gallardo Date: 2009/3/25 Subject: Re: [Haskell-cafe] Re: ANNOUNCE: WinGhci, a GUI for GHCI on Windows To: "Benjamin L.Russell" Hi Benjamin*,* ** The only requirement to run WinGhci is to have GHC installed and to have GHC bin directory on your

Re: [Haskell-cafe] Re: about Haskell code written to be "too smart"

2009-03-26 Thread Peter Verswyvelen
After reading the chapter about parsers in Bird's book, I tried to implement a simple parser myself, and this was a great experience, a real eye opener on how declarative and composable Haskell can be. Haskell is... well magic :-) It gave me same kind of joy I had when I made my first moving sprite

Re: [Haskell-cafe] about Haskell code written to be "too smart"

2009-03-26 Thread Colin Adams
2009/3/25 wren ng thornton : >>  Most of the "documentation" is in research papers, and a "normal" >>  programmer don't want to read these papers. > > Yes, and no. There is quite a bit of documentation in research papers, and > mainstream programmers don't read research. However, this is a big part