Re: [GHC] #3676: realToFrac doesn't sanely convert between floating types
#3676: realToFrac doesn't sanely convert between floating types --+- Reporter: draconx|Owner: simonmar Type: bug| Status: assigned Priority: normal |Milestone: _|_ Component: libraries (other) | Version: 6.12.1 Keywords: | Difficulty: Os: Unknown/Multiple | Testcase: Architecture: x86_64 (amd64) | Failure: None/Unknown --+- Changes (by simonmar): * milestone: 6.12.2 = _|_ Comment: I rolled back the patch to libraries/base: {{{ Tue Feb 23 10:16:03 GMT 2010 Simon Marlow marlo...@gmail.com * UNDO: Handle NaN, -Infinity and Infinity in the toRational for Float/Double (#3676) }}} in retrospect it wasn't a good idea to shoehorn these strange values into Rational. The position now is that `toRational (1/0 :: Double)` is undefined. The Haskell standard does not define the result (it should), and GHC gives unpredictable results. Hence, `realToFrac` cannot convert accurately between floating-point types. Someone should: * propose a proer API for conversion between floating-point types, e.g. `FloatConvert` above, but make a full proposal. * decide whether `toRational (1/0::Double)` should be undefined or an exception. If it is an exception, then we cannot optimise `realToFrac` to a direct conversion, e.g. `floatToDouble#`. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/3676#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #3864: Bad error message if $TMP does not exist
#3864: Bad error message if $TMP does not exist ---+ Reporter: NeilMitchell | Owner: Type: bug | Status: closed Priority: high | Milestone: 6.12.2 Component: Compiler |Version: 6.10.4 Resolution: fixed | Keywords: Difficulty:| Os: Windows Testcase:| Architecture: Unknown/Multiple Failure: None/Unknown | ---+ Changes (by igloo): * status: new = closed * resolution: = fixed Comment: Thanks for the report. The good news is that 6.12 already tells you the path in the exception. I'm not sure that we can easily give a better error message. We don't currently know where the path we're trying to create came from, and on Windows it looks like we get it by calling `GetTempPath` so we probably have no way of finding out that it was ultimately from `%TMP%`. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/3864#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: [GHC] #3181: Regression in unboxing
#3181: Regression in unboxing +--- Reporter: dolio|Owner: Type: bug | Status: new Priority: normal |Milestone: 6.12.2 Component: Compiler | Version: 6.10.2 Keywords: unboxing boxing | Difficulty: Unknown Os: Linux| Testcase: Architecture: x86_64 (amd64) | Failure: Runtime performance bug +--- Comment(by igloo): I can't reproduce this. With 6.8.2: {{{ $ ghc --version The Glorious Glasgow Haskell Compilation System, version 6.8.2 $ ghc -O -c Vector.hs $ ghc -O -c StrictPair.hs -ddump-simpl }}} I get this: {{{ $w$j_sBq = \ (w2_sAq :: GHC.Prim.State# GHC.Prim.RealWorld) (ww2_sAt :: GHC.Base.Int) (ww3_sAw :: GHC.Prim.Int#) - case w_sAC of wild11_auu { GHC.Base.I# x#_auw - case GHC.Prim.# x#_auw ww3_sAw of wild2_axd { GHC.Base.False - case GHC.Prim.==# x#_auw ww3_sAw of wild12_axg { GHC.Base.False - case GHC.Prim.writeIntArray# @ GHC.Prim.RealWorld arr_avS (GHC.Prim.+# ww_sAF 40) x#_auw w2_sAq of s'1_awJ { __DEFAULT - (# s'1_awJ, GHC.Base.() #) }; GHC.Base.True - case GHC.Prim.writeIntArray# @ GHC.Prim.RealWorld arr_avS (GHC.Prim.+# ww_sAF 40) x#_auw w2_sAq of s'1_awJ { __DEFAULT - (# s'1_awJ, GHC.Base.() #) } }; GHC.Base.True - case GHC.Prim.writeIntArray# @ GHC.Prim.RealWorld arr_avS (GHC.Prim.+# ww_sAF 40) ww3_sAw w2_sAq of s'1_awJ { __DEFAULT - case ww2_sAt of w3_XAV { GHC.Base.I# ww4_XBA - $wa_sBo wild11_auu ww4_XBA ww1_sAJ s'1_awJ } } } }}} which seems to have the same boxed `Int`. Can you say exactly how you are compiling it to get the result you want with 6.8.2 please? -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/3181#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler ___ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
FW: Installing syb(-0.1.03) package in head version of Haskell
Friends Can anyone help Kathleen out? She has a cabal-install issue. I think she's on a Mac. Many thanks Simon From: Kathleen Fisher [mailto:kathleen.fis...@gmail.com] Sent: 16 February 2010 22:54 To: Simon Peyton-Jones Subject: Fwd: Installing syb(-0.1.03) package in head version of Haskell Hi Simon, I'm trying to get the PADS file we were working on compiling under the HEAD version of Haskell, but I'm having trouble getting the Data.Generics module to install. I sent the question below to the librar...@haskell.orgmailto:librar...@haskell.org last week, but I haven't seen any replies. Is that the right address? Or is there a different place to ask such questions? Thanks for any pointers! Kathleen Begin forwarded message: From: Kathleen Fisher kathleen.fis...@gmail.commailto:kathleen.fis...@gmail.com Date: February 11, 2010 2:28:20 PM PST To: librar...@haskell.orgmailto:librar...@haskell.org Subject: Installing syb(-0.1.03) package in head version of Haskell Hi all, I'm trying to get a program that uses the Data.Generics module to compile under the head version of GHC, but I am having trouble getting the syb package installed. I believe I am using the most recent version of cabal: kfisher-laptop:/Users/kfisher/pads/dirpads/language-c-quote~/.cabal/bin/cabal --version cabal-install version 0.8.0 using version 1.8.0.1 of the Cabal library When I ask cabal to install the syb package, I get the following error: kfisher-laptop:/Users/kfisher/pads/dirpads/language-c-quote~/.cabal/bin/cabal install -w ~/sw/ghc-head/bin/ghc Resolving dependencies... Downloading mtl-1.1.0.2... Configuring mtl-1.1.0.2... Preprocessing library mtl-1.1.0.2... ... Registering syb-0.1.0.3... cabal: ghc-pkg: stdin: hGetContents: invalid argument (invalid UTF-8 byte sequence) cabal: Error: some packages failed to install: language-c-quote-0.1 depends on syb-0.1.0.3 which failed to install. syb-0.1.0.3 failed during the building phase. The exception was: exit: ExitFailure 1 The full trace is included below. Here's the version information for the ghc I am running. Kfisher-laptop:/Users/kfisher/pads/dirpads/language-c-quote~/sw/ghc-head/bin/ghc --version The Glorious Glasgow Haskell Compilation System, version 6.13.20100210 The cabal website suggests sending questions to this list... Any suggestions for how to fix this problem? Kathleen kfisher-laptop:/Users/kfisher/pads/dirpads/language-c-quote~/.cabal/bin/cabal install -w ~/sw/ghc-head/bin/ghc Resolving dependencies... Downloading mtl-1.1.0.2... Configuring mtl-1.1.0.2... Preprocessing library mtl-1.1.0.2... Building mtl-1.1.0.2... ...stuff deleted... src/Data/Generics.hs:40:1: Warning: The import of `Prelude' is redundant except perhaps to import instances from `Prelude' To import instances alone, use: import Prelude() Registering syb-0.1.0.3... cabal: ghc-pkg: stdin: hGetContents: invalid argument (invalid UTF-8 byte sequence) cabal: Error: some packages failed to install: language-c-quote-0.1 depends on syb-0.1.0.3 which failed to install. syb-0.1.0.3 failed during the building phase. The exception was: exit: ExitFailure 1 ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Installing syb(-0.1.03) package in head version of Haskell
I'm guessing that is indeed the problem, though I cannot reproduce the error (but I'm using Cabal-1.8.0.2). Assuming this is the cause of the problem, what is the best correction? Encoding the cabal file as UTF-8 or removing the accent? Do earlier versions of cabal deal well with UTF-8?... Cheers, Pedro On Tue, Feb 23, 2010 at 16:05, Bayley, Alistair alistair.bay...@invesco.com wrote: Just a wild guess, but the package description has this non-ascii text: author: Ralf Lämmel, Simon Peyton Jones It could well be Latin-1 encoded, rather than UTF8. Try editing the author field to this: author: Ralf Laemmel, Simon Peyton Jones and rebuilding/installing. -Original Message- From: glasgow-haskell-users-boun...@haskell.org [mailto:glasgow-haskell-users-boun...@haskell.org] On Behalf Of Simon Peyton-Jones Sent: 23 February 2010 14:32 To: GHC users Cc: cvs-...@haskell.org Subject: FW: Installing syb(-0.1.03) package in head version of Haskell Friends Can anyone help Kathleen out? She has a cabal-install issue. I think she's on a Mac. Many thanks Simon From: Kathleen Fisher [mailto:kathleen.fis...@gmail.com] Sent: 16 February 2010 22:54 To: Simon Peyton-Jones Subject: Fwd: Installing syb(-0.1.03) package in head version of Haskell Hi Simon, I'm trying to get the PADS file we were working on compiling under the HEAD version of Haskell, but I'm having trouble getting the Data.Generics module to install. I sent the question below to the librar...@haskell.org last week, but I haven't seen any replies. Is that the right address? Or is there a different place to ask such questions? Thanks for any pointers! Kathleen Begin forwarded message: From: Kathleen Fisher kathleen.fis...@gmail.com Date: February 11, 2010 2:28:20 PM PST To: librar...@haskell.org Subject: Installing syb(-0.1.03) package in head version of Haskell Hi all, I'm trying to get a program that uses the Data.Generics module to compile under the head version of GHC, but I am having trouble getting the syb package installed. I believe I am using the most recent version of cabal: kfisher-laptop:/Users/kfisher/pads/dirpads/language-c-quote~/ .cabal/bin/cabal --version cabal-install version 0.8.0 using version 1.8.0.1 of the Cabal library When I ask cabal to install the syb package, I get the following error: kfisher-laptop:/Users/kfisher/pads/dirpads/language-c-quote~/ .cabal/bin/cabal install -w ~/sw/ghc-head/bin/ghc Resolving dependencies... Downloading mtl-1.1.0.2... Configuring mtl-1.1.0.2... Preprocessing library mtl-1.1.0.2... ... Registering syb-0.1.0.3... cabal: ghc-pkg: stdin: hGetContents: invalid argument (invalid UTF-8 byte sequence) cabal: Error: some packages failed to install: language-c-quote-0.1 depends on syb-0.1.0.3 which failed to install. syb-0.1.0.3 failed during the building phase. The exception was: exit: ExitFailure 1 The full trace is included below. Here's the version information for the ghc I am running. Kfisher-laptop:/Users/kfisher/pads/dirpads/language-c-quote~/ sw/ghc-head/bin/ghc --version The Glorious Glasgow Haskell Compilation System, version 6.13.20100210 The cabal website suggests sending questions to this list... Any suggestions for how to fix this problem? Kathleen kfisher-laptop:/Users/kfisher/pads/dirpads/language-c-quote~/ .cabal/bin/cabal install -w ~/sw/ghc-head/bin/ghc Resolving dependencies... Downloading mtl-1.1.0.2... Configuring mtl-1.1.0.2... Preprocessing library mtl-1.1.0.2... Building mtl-1.1.0.2... ...stuff deleted... src/Data/Generics.hs:40:1: Warning: The import of `Prelude' is redundant except perhaps to import instances from `Prelude' To import instances alone, use: import Prelude() Registering syb-0.1.0.3... cabal: ghc-pkg: stdin: hGetContents: invalid argument (invalid UTF-8 byte sequence) cabal: Error: some packages failed to install: language-c-quote-0.1 depends on syb-0.1.0.3 which failed to install. syb-0.1.0.3 failed during the building phase. The exception was: exit: ExitFailure 1 * Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in
RE: Installing syb(-0.1.03) package in head version of Haskell
Thanks! I forgot to cc Kathleen herself, so I'm now doing so. Assuming that's the problem, does it reflect a bug in Cabal, or GHC, or what? And if so, can someone make a ticket?] Thanks Simon From: José Pedro Magalhães [mailto:j...@cs.uu.nl] Sent: 23 February 2010 15:10 To: Bayley, Alistair Cc: Simon Peyton-Jones; GHC users; cvs-...@haskell.org Subject: Re: Installing syb(-0.1.03) package in head version of Haskell I'm guessing that is indeed the problem, though I cannot reproduce the error (but I'm using Cabal-1.8.0.2). Assuming this is the cause of the problem, what is the best correction? Encoding the cabal file as UTF-8 or removing the accent? Do earlier versions of cabal deal well with UTF-8?... Cheers, Pedro On Tue, Feb 23, 2010 at 16:05, Bayley, Alistair alistair.bay...@invesco.commailto:alistair.bay...@invesco.com wrote: Just a wild guess, but the package description has this non-ascii text: author: Ralf Lämmel, Simon Peyton Jones It could well be Latin-1 encoded, rather than UTF8. Try editing the author field to this: author: Ralf Laemmel, Simon Peyton Jones and rebuilding/installing. -Original Message- From: glasgow-haskell-users-boun...@haskell.orgmailto:glasgow-haskell-users-boun...@haskell.org [mailto:glasgow-haskell-users-boun...@haskell.orgmailto:glasgow-haskell-users-boun...@haskell.org] On Behalf Of Simon Peyton-Jones Sent: 23 February 2010 14:32 To: GHC users Cc: cvs-...@haskell.orgmailto:cvs-...@haskell.org Subject: FW: Installing syb(-0.1.03) package in head version of Haskell Friends Can anyone help Kathleen out? She has a cabal-install issue. I think she's on a Mac. Many thanks Simon From: Kathleen Fisher [mailto:kathleen.fis...@gmail.commailto:kathleen.fis...@gmail.com] Sent: 16 February 2010 22:54 To: Simon Peyton-Jones Subject: Fwd: Installing syb(-0.1.03) package in head version of Haskell Hi Simon, I'm trying to get the PADS file we were working on compiling under the HEAD version of Haskell, but I'm having trouble getting the Data.Generics module to install. I sent the question below to the librar...@haskell.orgmailto:librar...@haskell.org last week, but I haven't seen any replies. Is that the right address? Or is there a different place to ask such questions? Thanks for any pointers! Kathleen Begin forwarded message: From: Kathleen Fisher kathleen.fis...@gmail.commailto:kathleen.fis...@gmail.com Date: February 11, 2010 2:28:20 PM PST To: librar...@haskell.orgmailto:librar...@haskell.org Subject: Installing syb(-0.1.03) package in head version of Haskell Hi all, I'm trying to get a program that uses the Data.Generics module to compile under the head version of GHC, but I am having trouble getting the syb package installed. I believe I am using the most recent version of cabal: kfisher-laptop:/Users/kfisher/pads/dirpads/language-c-quote~/ .cabal/bin/cabal --version cabal-install version 0.8.0 using version 1.8.0.1 of the Cabal library When I ask cabal to install the syb package, I get the following error: kfisher-laptop:/Users/kfisher/pads/dirpads/language-c-quote~/ .cabal/bin/cabal install -w ~/sw/ghc-head/bin/ghc Resolving dependencies... Downloading mtl-1.1.0.2... Configuring mtl-1.1.0.2... Preprocessing library mtl-1.1.0.2... ... Registering syb-0.1.0.3... cabal: ghc-pkg: stdin: hGetContents: invalid argument (invalid UTF-8 byte sequence) cabal: Error: some packages failed to install: language-c-quote-0.1 depends on syb-0.1.0.3 which failed to install. syb-0.1.0.3 failed during the building phase. The exception was: exit: ExitFailure 1 The full trace is included below. Here's the version information for the ghc I am running. Kfisher-laptop:/Users/kfisher/pads/dirpads/language-c-quote~/ sw/ghc-head/bin/ghc --version The Glorious Glasgow Haskell Compilation System, version 6.13.20100210 The cabal website suggests sending questions to this list... Any suggestions for how to fix this problem? Kathleen kfisher-laptop:/Users/kfisher/pads/dirpads/language-c-quote~/ .cabal/bin/cabal install -w ~/sw/ghc-head/bin/ghc Resolving dependencies... Downloading mtl-1.1.0.2... Configuring mtl-1.1.0.2... Preprocessing library mtl-1.1.0.2... Building mtl-1.1.0.2... ...stuff deleted... src/Data/Generics.hs:40:1: Warning: The import of `Prelude' is redundant except perhaps to import instances from `Prelude' To import instances alone, use: import Prelude() Registering syb-0.1.0.3... cabal: ghc-pkg: stdin: hGetContents: invalid argument (invalid UTF-8 byte sequence) cabal: Error: some packages failed to install: language-c-quote-0.1
Re: Installing syb(-0.1.03) package in head version of Haskell
On Tue, Feb 23, 2010 at 03:05:56PM -, Bayley, Alistair wrote: Just a wild guess, but the package description has this non-ascii text: author: Ralf Lämmel, Simon Peyton Jones It could well be Latin-1 encoded, rather than UTF8. No, syb-0.1.0.3/syb.cabal is UTF-8-encoded (conforming to the Cabal docs). Try editing the author field to this: author: Ralf Laemmel, Simon Peyton Jones and rebuilding/installing. If it's a ghc-pkg problem, that might work. ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: integer-simple by default
Hello, Yet another data point would be my current use of Haskell in various integer factorization activities where I would consider the performance, even for relatively large integers (say, 100-1000 decimal digits) very important. However, I wouldn't complain if some simple and manageable implementation were introduced, as long as the re-introduction of the efficient use of some well-tuned library (like GMP) were not hampered needlessly. Best regards Thorkil - Original meddelelse - Fra: Yitzchak Gale g...@sefer.org Til: Greg Fitzgerald gari...@gmail.com Cc: glasgow-haskell-users@haskell.org Dato: Tir, 23. feb 2010 00:04 Emne: Re: integer-simple by default I wrote: As another data point, Python has also re-invented the GMP wheel, likely for the same licensing reasons. They have been using a simple implementation of Karatsuba multiplication for years. I have never heard of anyone complaining about it Greg Fitzgerald wrote: Looks like they swapped out their integer implementation for Python3 Interesting! This will be new in Python 3.2 - the first changes in many years. It's not exactly swapped out, but there are many changes. At first glance, it looks like better 64-bit support, a new division algorithm via floating-point, a new exponentiation algorithm using a 5-bits-at-a-time trick in some cases, optimized Read and Show instances (pardon the expression), a few other things. A lot of the new stuff seems to be from HAC. As before, everything is fully explained in expository comments inside the code, with references; a worthwhile read. Multiplication is still the same basic idea though - naive up to about 2000 bits, followed by just Karatsuba and nothing more. Thanks, Yitz ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Installing syb(-0.1.03) package in head version of Haskell
On Tue, Feb 23, 2010 at 10:12 AM, Ross Paterson r...@soi.city.ac.uk wrote: On Tue, Feb 23, 2010 at 03:05:56PM -, Bayley, Alistair wrote: Just a wild guess, but the package description has this non-ascii text: author: Ralf Lämmel, Simon Peyton Jones It could well be Latin-1 encoded, rather than UTF8. No, syb-0.1.0.3/syb.cabal is UTF-8-encoded (conforming to the Cabal docs). I had similar issues when attempting to install a new version of syb over an old version[1]. I had to open this file in emacs: /usr/lib/ghc-6.13/package.conf.d/syb-0.1.0.3.conf and the do: M-x set-buffer-file-coding-system utf-8 I think there was a point in time where something wrote contains to that file as latin1 instead of utf-8 or something. - jeremy [1] it might have actually been the same version of syb, but rebuilt with a different version of the compiler or something.. ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Installing syb(-0.1.03) package in head version of Haskell
Ross Paterson schrieb: On Tue, Feb 23, 2010 at 03:05:56PM -, Bayley, Alistair wrote: Just a wild guess, but the package description has this non-ascii text: author: Ralf Lämmel, Simon Peyton Jones It could well be Latin-1 encoded, rather than UTF8. No, syb-0.1.0.3/syb.cabal is UTF-8-encoded (conforming to the Cabal docs). My guess would be that the locale is not properly set. The environment variable LANG should be set to something shown by locale -a (i.e en_GB). Other LC_* variables should not be set. The variables should not be C or POSIX. (I was able to install syb-0.1.0.3 without a problem) Cheers Christian Try editing the author field to this: author: Ralf Laemmel, Simon Peyton Jones and rebuilding/installing. If it's a ghc-pkg problem, that might work. ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Shared GHC libraries and the runtime system
The usual way to do this would be to include the dependency on the RTS in the library and then vary the RTS by using LD_PRELOAD. I think ghc does it the wrong way. -- Lennart On Mon, Feb 22, 2010 at 10:00 PM, Max Bolingbroke batterseapo...@hotmail.com wrote: Hi Tyson, This blog post (http://blog.well-typed.com/2009/05/buildings-plugins-as-haskell-shared-libs/) might help explain the motivation (actually there are a few relevant posts on the well-typed site). Essentially, I believe that this is done so that you can vary the RTS by changing LD_LIBRARY_PATH. I've never used this facility so I'm unable to say how useful this actually is (or if it actually works at the moment). Cheers, Max On 22 February 2010 21:34, Tyson Whitehead twhiteh...@gmail.com wrote: I was working on a shared library that loads up the GHC runtime (via hs_init) and have been running into a bunch of undefined stg symbols. A bit of digging and it seems that GHC doesn't embed - the dependency libHSrts-ghc6.12.1.so, and - the associated rpath /usr/lib/ghc-6.12.1 into shared libraries that it builds. Thus, if your main executable isn't GHC generated (and hence has these), you run into unresolved symbols. I can work around this by manually adding them myself. Is there any reason GHC can't put this information by default into shared libraries though? Thanks! -Tyson PS: Further digging into the various shared libraries packaged with GHC (Debian GHC package 6.12.1-2) reveal that they are actually missing - the dependency libHSrts-ghc6.12.1.so, and - all rpaths (i.e., there are absolutely no rpaths in any of them) $ objdump -p /usr/lib/ghc-6.12.1/base-4.2.0.0/libHSbase-4.2.0.0-ghc6.12.1.so ... Dynamic Section: NEEDED libHSinteger-gmp-0.2.0.0-ghc6.12.1.so NEEDED libgmp.so.3 NEEDED libHSghc-prim-0.2.0.0-ghc6.12.1.so NEEDED libc.so.6 SONAME libHSbase-4.2.0.0-ghc6.12.1.so ... ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Installing syb(-0.1.03) package in head version of Haskell
On Tue, Feb 23, 2010 at 12:46 PM, Christian Maeder christian.mae...@dfki.de wrote: Ross Paterson schrieb: On Tue, Feb 23, 2010 at 03:05:56PM -, Bayley, Alistair wrote: Just a wild guess, but the package description has this non-ascii text: author: Ralf Lämmel, Simon Peyton Jones It could well be Latin-1 encoded, rather than UTF8. No, syb-0.1.0.3/syb.cabal is UTF-8-encoded (conforming to the Cabal docs). My guess would be that the locale is not properly set. The environment variable LANG should be set to something shown by locale -a (i.e en_GB). Other LC_* variables should not be set. The variables should not be C or POSIX. (I was able to install syb-0.1.0.3 without a problem) Cheers Christian If we're relying on the locale being set properly is the fix then to force insert tool here to always read in Cabal package descriptions as UTF-8? Antoine ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Installing syb(-0.1.03) package in head version of Haskell
On 23/02/10 18:46, Christian Maeder wrote: Ross Paterson schrieb: On Tue, Feb 23, 2010 at 03:05:56PM -, Bayley, Alistair wrote: Just a wild guess, but the package description has this non-ascii text: author: Ralf Lämmel, Simon Peyton Jones It could well be Latin-1 encoded, rather than UTF8. No, syb-0.1.0.3/syb.cabal is UTF-8-encoded (conforming to the Cabal docs). My guess would be that the locale is not properly set. The environment variable LANG should be set to something shown by locale -a (i.e en_GB). Other LC_* variables should not be set. The variables should not be C or POSIX. (I was able to install syb-0.1.0.3 without a problem) Both Cabal and ghc-pkg explicitly use UTF-8 for handling .cabal and package configuration files, so if you end up with a Latin-1 file in your package database then something has gone wrong. If anyone can reproduce this problem then please submit a ticket. Cheers, Simon ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: GHC FFI stub files
On Feb 21, 2010, at 23:46 , Tyson Whitehead wrote: I'm writing a perl module that interfaces some haskell code and its a bit of a pain because both perl and ghc have their own custom build system. Is there a way to get ghc to give you the gcc/as/ld options (library paths, include paths, flags, etc) required for the FFI stub files it generates? -n -v3 might be helpful. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
[Haskell] Re: Haskell Weekly News: Issue 150 - February 22, 2010
jfred...@gmail.com wrote: [snip] From the very pits of Harddrive failure I return... The Haskell Weekly News Reborn! Last week, on friday, my HWN machine suffered what can only be appropriately named a unbelievably poorly timed hard drive failure, hence the lack of an HWN That sounds like a disaster to me; do you keep a backup of the contents of your hard drive (at least the HWN-related material)? -- Benjamin L. Russell -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 Furuike ya, kawazu tobikomu mizu no oto. -- Matsuo Basho^ ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
location of Haskell reports
Should not be there a link to Haskell 2010 report on this page? http://haskell.org/haskellwiki/Language_and_library_specification That is if Haskell 2010 is finalized. Where is the standard location to find Haskel Prime reports? Peter. ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
Re: Proposal: Hexadecimal floating point constants
On 12:26 Sat 20 Feb , Heinrich Apfelmus wrote: Nick Bowler wrote: Similarly, the greatest finite double value can be written as 0x1.fp+1023. These constants have the form 0x[HH][.H]p[+/-]DDD If you don't want to wait on an (uncertain) inclusion into the Haskell standard, you can implement a small helper function to that effect yourself; essentially using encodeFloat . Indeed, I have already implemented such a function. My gripe here is that it's extremely cumbersome to use such a function in a program, and it adds the possibily of programs crashing due to syntax errors at runtime. On 13:15 Mon 22 Feb , Simon Peyton-Jones wrote: Or, alternatively, use quasiquoting [hex| 1.fp+1023 |] Ah, I was not aware of this feature. It does seem like a decent solution, in that it allows errors to be caught at compile time. Somewhat more verbose than I had hoped, but it's probably fine. Thanks. -- Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/) ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
Re: location of Haskell reports
On Tue, Feb 23, 2010 at 10:55 AM, Peter Hercek pher...@gmail.com wrote: Should not be there a link to Haskell 2010 report on this page? Simon wrote on another thread that he plans to work on it next month. David. ___ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime
Re: [Haskell-cafe] grapefruit on windows or osX
Am Sonntag, 21. Februar 2010 21:57:45 schrieb gladst...@gladstein.com: I'm unable to get grapefruit going on osx or windows because (I think) I can't get the underlying GTK installed. Hi, thank you for giving Grapefruit a try. Yes, you are most likely right that Gtk2Hs is the stumbling block. Grapefruit itself doesn’t do anything OS-specific, and since it works on Linux, it should also work on OS X. I strongly suggest that you try out the current development version of Grapefruit instead of the version on Hackage, since the latter is lacking a bunch of features. If you have any Grapefruit-related questions, please ask here or on the Grapefruit mailing list. Best wishes, Wolfgang ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Alex Lexer: Trying to get rid of Alex
Hi Haskell-cafe My problem: I'm trying to obtain the current position of the lexer once it reaches the end of the file (line and row number). I'm trying to do this in a function: getEndPosition = do (a,b,c) - alexGetInput return a Unfortunately, the type of a is 'Alex AlexPosn' instead of just 'AlexPosn' How do I strip the Alex so I'm left with just a AlexPosn object? Thanks, Amit Deshwar University of Calgary ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Alex Lexer: Trying to get rid of Alex
On 23 February 2010 20:15, Amit Deshwar amit.desh...@gmail.com wrote: Hi Haskell-cafe My problem: I'm trying to obtain the current position of the lexer once it reaches the end of the file (line and row number). I'm trying to do this in a function: getEndPosition = do (a,b,c) - alexGetInput return a Unfortunately, the type of a is 'Alex AlexPosn' instead of just 'AlexPosn' How do I strip the Alex so I'm left with just a AlexPosn object? Hi Amit, Are you sure about the type of a? It looks like you are using the monad wrapper, described here: http://www.haskell.org/alex/doc/html/wrappers.html If that is true, then: alexGetInput :: Alex AlexInput and type AlexInput = (AlexPosn, Char, String) From that we can infer from your code: getEndPosition :: Alex AlexPosn and thus: a :: AlexPosn If you want to manipulate the value bound to a, you can simply apply a function to it in the body of getEndPosition, and return the result of that application (still inside the Alex type). Or you can use the function: runAlex :: String - Alex a - Either String a Cheers, Bernie. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parsing of bytestrings with non-String errors?
On Tue, Feb 23, 2010 at 00:39, Bryan O'Sullivan b...@serpentine.com wrote: On Mon, Feb 22, 2010 at 2:38 PM, Magnus Therning mag...@therning.org wrote: My thoughts went more like a parser type like data Parser e a = ... Yes, I knew that's where you were going :-) The trouble is, you'd still have to deal with fail :: Monad m = String - m a which would require your failure type to somehow accept a string. Plumbing that in would be a little more awkward than your initial exporations suggest :-\ You have two problems. The first is how to construct a value of your failure type that accepts a String parameter so that you can support users of fail. The second is that you might need to pass extra information to construct your failure value when naïve code uses fail or mzero, otherwise you will only get useful error values out quite infrequently. Yes, I suspected there'd be something I had missed. I guess it'd would require 'Parser e a' to have a 'fail' that's similar to the one in 'Maybe'. Users would then be forced to use '?' to get useful error info out. Would that be an unworkable situation? I still haven't convinced myself that this will work though. Also, I had a look at attoparsec on bitbucket, and there are some major changes between 0.7 and 0.8. Even though those changes represent a major modification to the internals of attoparsec, they shouldn't really affect what you want to do, or anything interesting about how to do it. Ah, that's good. I think I'll have to postpone any work on this for now though, and instead implement a 'String - MyErrorType' function for, hopefully, temporary use. I've already been sidetracked twice before ;-) /M -- Magnus Therning(OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Function to detect duplicates
Hi folks, While solving a puzzle, I was posed the problem of finding if there was no duplicates on a list. First I used: noneRepeated=null.(filter (1)).(map length).group.sort But this seemed very unneficient, so I thought that I could detect the duplicates while sorting, and devised this: import Control.Monad import Data.Maybe noneRepeated=isNothing . (foldl merge (Just [])) . (map sort) . pairs pairs []=[] pairs [x]=[[x]] pairs (x:y:xs)=[x,y]:pairs xs sort []=Just [] sort [x]=Just [x] sort [x,y] | xy=Just [y,x] | yx=Just [x,y] | x==y=Nothing merge::(Eq a, Ord a) = Maybe [a]-Maybe [a]-Maybe[a] merge _ Nothing = Nothing merge Nothing _ = Nothing merge (Just []) (Just xs)=Just xs merge (Just xs) (Just [])=Just xs merge (Just (x:xs)) (Just (y:ys)) | x==y = Nothing | xy = (Just y) +? (merge (Just (x:xs)) (Just ys)) | xy = (Just x) +? (merge (Just xs) (Just (y:ys))) (+?) = liftM2 (:) My version of the merge sort returns Nothing whenever it finds two equal entries, aborting all subsequent comparisons. I have a few questions for the friendly people at this cafe: 1) Is there any improvement I can make? 2) Can it be parallelized (par, pseq)? Best regards, Rafael ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Function to detect duplicates
Hi Rafael, I assume you will perform this operation on some very large lists, or performance would not be an issue. Have you tested if your optimized version is better than your initial one? You should compare your implementation against something like this: import qualified Data.Set as Set noneRepeated :: (Ord a) = [a] - Bool noneRepeated = accum Set.empty where accum _ [] = True accum s (x:xs) | Set.member x s = False | otherwise = accum (Set.insert x s) xs Also there is some discussion about the nub function that relates to this topic, e.g. http://buffered.io/2008/07/28/a-better-nub/. /Jonas On 23 February 2010 12:30, Rafael Gustavo da Cunha Pereira Pinto rafaelgcpp.li...@gmail.com wrote: Hi folks, While solving a puzzle, I was posed the problem of finding if there was no duplicates on a list. First I used: noneRepeated=null.(filter (1)).(map length).group.sort But this seemed very unneficient, so I thought that I could detect the duplicates while sorting, and devised this: import Control.Monad import Data.Maybe noneRepeated=isNothing . (foldl merge (Just [])) . (map sort) . pairs pairs []=[] pairs [x]=[[x]] pairs (x:y:xs)=[x,y]:pairs xs sort []=Just [] sort [x]=Just [x] sort [x,y] | xy=Just [y,x] | yx=Just [x,y] | x==y=Nothing merge::(Eq a, Ord a) = Maybe [a]-Maybe [a]-Maybe[a] merge _ Nothing = Nothing merge Nothing _ = Nothing merge (Just []) (Just xs)=Just xs merge (Just xs) (Just [])=Just xs merge (Just (x:xs)) (Just (y:ys)) | x==y = Nothing | xy = (Just y) +? (merge (Just (x:xs)) (Just ys)) | xy = (Just x) +? (merge (Just xs) (Just (y:ys))) (+?) = liftM2 (:) My version of the merge sort returns Nothing whenever it finds two equal entries, aborting all subsequent comparisons. I have a few questions for the friendly people at this cafe: 1) Is there any improvement I can make? 2) Can it be parallelized (par, pseq)? Best regards, Rafael ___ 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
[Haskell-cafe] Profiling OpenGL applications
On Sunday, Andrew Coppin asked: Is Thread Scope any use for profiling single-threaded programs? I used threadscope to look at eventlogs from a program that uses OpenGL to render multiple frames per second (compiled without -threaded). That means, there is CPU activity regularly (multiple times per second), and this can be observed via threadscope and i found it somewhat useful. There are some problems, though: 1. I can't definitely tell, which time span corresponds to CPU activity for the calculations for one frame. Is it possible to generate threadscope bookmarks from within the profiled program? (Or other events that can be shown in threadscope?) 2. The GPU activity cannot be observed. This is not a problem specific to Haskell, though. Is it even possible (with end user hardware) to get something similar to threadscope, not for CPU, but GPU activity? Any other ideas, that might help gathering information, about what's going on on the CPU(s) and the GPU? Many thanks, Sönke ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Function to detect duplicates
Rafael Gustavo da Cunha Pereira Pinto rafaelgcpp.li...@gmail.com wrote: While solving a puzzle, I was posed the problem of finding if there was no duplicates on a list. First I used: noneRepeated=null.(filter (1)).(map length).group.sort But this seemed very unneficient, so I thought that I could detect the duplicates while sorting, and devised this: import Control.Monad import Data.Maybe noneRepeated=isNothing . (foldl merge (Just [])) . (map sort) . pairs import Data.List noneRepeated xs = xs == nub xs Greets Ertugrul -- nightmare = unsafePerformIO (getWrongWife = sex) http://blog.ertes.de/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Function to detect duplicates
Am Dienstag 23 Februar 2010 13:03:45 schrieb Ertugrul Soeylemez: Rafael Gustavo da Cunha Pereira Pinto rafaelgcpp.li...@gmail.com wrote: While solving a puzzle, I was posed the problem of finding if there was no duplicates on a list. First I used: noneRepeated=null.(filter (1)).(map length).group.sort But this seemed very unneficient, so I thought that I could detect the duplicates while sorting, and devised this: import Control.Monad import Data.Maybe noneRepeated=isNothing . (foldl merge (Just [])) . (map sort) . pairs import Data.List noneRepeated xs = xs == nub xs Talk about inefficiency :) import Data.Set (Set) import qualified Data.Set as Set noneRepeated = go 0 Set.empty where go ct st (x:xs) | Set.size st ct = False | otherwise = go (ct+1) (Set.insert x st) xs go ct st [] = ct == Set.size st Greets Ertugrul ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Function to detect duplicates
Ertugrul: while your solution is minimalistic, Rafael deemed his ~n*log n implementation too inefficient. Thus your ~n^3 implementation is hardly an improvement... /Jonas On 23 February 2010 13:03, Ertugrul Soeylemez e...@ertes.de wrote: Rafael Gustavo da Cunha Pereira Pinto rafaelgcpp.li...@gmail.com wrote: While solving a puzzle, I was posed the problem of finding if there was no duplicates on a list. First I used: noneRepeated=null.(filter (1)).(map length).group.sort But this seemed very unneficient, so I thought that I could detect the duplicates while sorting, and devised this: import Control.Monad import Data.Maybe noneRepeated=isNothing . (foldl merge (Just [])) . (map sort) . pairs import Data.List noneRepeated xs = xs == nub xs Greets Ertugrul -- nightmare = unsafePerformIO (getWrongWife = sex) http://blog.ertes.de/ ___ 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] Function to detect duplicates
Rafael Gustavo da Cunha Pereira Pinto rafaelgcpp.li...@gmail.com writes: First I used: noneRepeated=null.(filter (1)).(map length).group.sort But this seemed very unneficient, so I thought that I could detect the duplicates while sorting, and devised this: [...] 1) Is there any improvement I can make? Well - it's a bit long, don't you think? Long enough that from a cursory glance, I'd say it's in the no obvious errors category. How about (inspired by quicksort, as you no doubt can tell): noneRepeated [] = True noneRepeated (x:xs) = noneRepeated lt singleton eq noneRepeated gt where lt = filter (x) xs gt = filter (x) xs eq = x:filter (==x) xs singleton [_] = True singleton _ = False 2) Can it be parallelized (par, pseq)? You could force each of the sublists in parallel, but you might lose some laziness properties, so I'd carefully benchmark it. -k -- If I haven't seen further, it is by standing in the footprints of giants ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Function to detect duplicates
Jonas Almström Duregård jonas.dureg...@gmail.com wrote: Ertugrul: while your solution is minimalistic, Rafael deemed his ~n*log n implementation too inefficient. Thus your ~n^3 implementation is hardly an improvement... My variant has an advantage, though. It is completely lazy, so it will take a shortcut, as soon as a duplicate is found. Depending on his application, this may be useful or not. I think the nub-based solution is the best one in general, but it's the base library implementation of nub, which is unfortunate. In fact, with a better nub implementation, this becomes an O(n * log n) time algorithm, too, but with the additional laziness advantage. The article you linked to contains such an implementation, I think. Greets Ertugrul -- nightmare = unsafePerformIO (getWrongWife = sex) http://blog.ertes.de/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Function to detect duplicates
Am Dienstag 23 Februar 2010 13:59:49 schrieb Ertugrul Soeylemez: Jonas Almström Duregård jonas.dureg...@gmail.com wrote: Ertugrul: while your solution is minimalistic, Rafael deemed his ~n*log n implementation too inefficient. Thus your ~n^3 implementation is hardly an improvement... Not quite as bad, nub is O(n^2). My variant has an advantage, though. It is completely lazy, so it will take a shortcut, as soon as a duplicate is found. Depending on his application, this may be useful or not. I think the nub-based solution is the best one in general, but it's the base library implementation of nub, which is unfortunate. In fact, with a better nub implementation, this becomes an O(n * log n) time How can you nub in O(n*log n)? Remember, you only have Eq for nub. algorithm, too, but with the additional laziness advantage. The article you linked to contains such an implementation, I think. Greets Ertugrul ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Proper round-trip HughesPJ/Parsec for Doubles?
Hi all, Short version: How can I pretty print and parse values of type Double such that those operations are each other's inverse? Long version: I'm writing and QuickCheck-testing a parser using the approach set out here: http://lstephen.wordpress.com/2007/07/29/parsec-parser-testing-with-quickcheck/ That is, each syntactic category gets a pretty-printer and a parser and an Arbitrary instance, and QuickCheck checks that (parse . prettyPrint) == id, basically. Somewhat unsurprisingly, this sometimes fails for floating point values (I'm using Doubles). Now, I know that floats are in some sense imprecise, and comparing for equality is fraught with peril, but it seems that if x==x then it ought to be at least _possible_ to arrange matters such that (parse . prettyPrint x) == x as well. At worst, pretty-printing the underlying binary representation!? So my feeling is that my parser could be improved. At the moment I'm working around it by defining a type class which checks for equality within some margin of error, and using that instead of Eq - but it's messier than I'd like, so I wondered if there was something obvious I'm missing. As hpaste.org seems to be down, I'll attach a code example here instead. Thanks! -Andy -- Andy Gimblett http://gimbo.org.uk/ TestParse.hs Description: Binary data ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Function to detect duplicates
noneRepeated xs = xs == nub xs Not quite as bad, nub is O(n^2) You are correct of course. Still, it will probably be a bit less inefficient if the length of the lists are compared (as opposed to the elements): noneRepeated xs = length xs == length (nub xs) On 23 February 2010 14:09, Daniel Fischer daniel.is.fisc...@web.de wrote: Am Dienstag 23 Februar 2010 13:59:49 schrieb Ertugrul Soeylemez: Jonas Almström Duregård jonas.dureg...@gmail.com wrote: Ertugrul: while your solution is minimalistic, Rafael deemed his ~n*log n implementation too inefficient. Thus your ~n^3 implementation is hardly an improvement... Not quite as bad, nub is O(n^2). My variant has an advantage, though. It is completely lazy, so it will take a shortcut, as soon as a duplicate is found. Depending on his application, this may be useful or not. I think the nub-based solution is the best one in general, but it's the base library implementation of nub, which is unfortunate. In fact, with a better nub implementation, this becomes an O(n * log n) time How can you nub in O(n*log n)? Remember, you only have Eq for nub. algorithm, too, but with the additional laziness advantage. The article you linked to contains such an implementation, I think. Greets Ertugrul ___ 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] Re: Function to detect duplicates
Am Dienstag 23 Februar 2010 14:54:36 schrieb Jonas Almström Duregård: You are correct of course. Still, it will probably be a bit less inefficient if the length of the lists are compared (as opposed to the elements): noneRepeated xs = length xs == length (nub xs) Only if no repeated elements appear early. For xs = 1 : [1 .. 10^7], xs == nub xs will return False without noticeable delay, length xs == length (nub xs) will take VERY long. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Proper round-trip HughesPJ/Parsec for Doubles?
Am Dienstag 23 Februar 2010 14:44:50 schrieb Andy Gimblett: Hi all, Short version: How can I pretty print and parse values of type Double such that those operations are each other's inverse? Long version: I'm writing and QuickCheck-testing a parser using the approach set out here: http://lstephen.wordpress.com/2007/07/29/parsec-parser-testing-with-quic kcheck/ That is, each syntactic category gets a pretty-printer and a parser and an Arbitrary instance, and QuickCheck checks that (parse . prettyPrint) == id, basically. Somewhat unsurprisingly, this sometimes fails for floating point values (I'm using Doubles). Now, I know that floats are in some sense imprecise, and comparing for equality is fraught with peril, but it seems that if x==x then it ought to be at least _possible_ to arrange matters such that (parse . prettyPrint x) == x as well. At worst, pretty-printing the underlying binary representation!? So my feeling is that my parser could be improved. Parse it as a Rational, then convert with fromRational. I don't know whether that will always have parse . prettyPrint == id, but it'll be much closer. The naturalOrFloat default implementation uses fraction= do{ char '.' ; digits - many1 digit ? fraction ; return (foldr op 0.0 digits) } ? fraction where op d f= (f + fromIntegral (digitToInt d))/10.0 and division by 10 isn't exact with a binary representation. At the moment I'm working around it by defining a type class which checks for equality within some margin of error, and using that instead of Eq - but it's messier than I'd like, so I wondered if there was something obvious I'm missing. As hpaste.org seems to be down, I'll attach a code example here instead. Thanks! -Andy -- Andy Gimblett http://gimbo.org.uk/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Proper round-trip HughesPJ/Parsec for Doubles?
Andy Gimblett schrieb: Hi all, Short version: How can I pretty print and parse values of type Double such that those operations are each other's inverse? Maybe you have more luck with show and read (without Parsec.Token). Your example: x = 9.91165677454629 fails because the computation performed by the parser 9.0 + 0.91165677454629 yields 9.911656774546291 Cheers Christian Long version: I'm writing and QuickCheck-testing a parser using the approach set out here: http://lstephen.wordpress.com/2007/07/29/parsec-parser-testing-with-quickcheck/ That is, each syntactic category gets a pretty-printer and a parser and an Arbitrary instance, and QuickCheck checks that (parse . prettyPrint) == id, basically. Somewhat unsurprisingly, this sometimes fails for floating point values (I'm using Doubles). Now, I know that floats are in some sense imprecise, and comparing for equality is fraught with peril, but it seems that if x==x then it ought to be at least _possible_ to arrange matters such that (parse . prettyPrint x) == x as well. At worst, pretty-printing the underlying binary representation!? So my feeling is that my parser could be improved. At the moment I'm working around it by defining a type class which checks for equality within some margin of error, and using that instead of Eq - but it's messier than I'd like, so I wondered if there was something obvious I'm missing. As hpaste.org seems to be down, I'll attach a code example here instead. Thanks! -Andy -- Andy Gimblett http://gimbo.org.uk/ ___ 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
[Haskell-cafe] Re: Proper round-trip HughesPJ/Parsec for Doubles?
Short version: How can I pretty print and parse values of type Double such that those operations are each other's inverse? Maybe you have more luck with show and read (without Parsec.Token). Your example: x = 9.91165677454629 fails because the computation performed by the parser 9.0 + 0.91165677454629 yields 9.911656774546291 That seems to do the trick! Below, for the record, the code I've come up with (I threw away the Either Integer Double part so it's a bit simpler, also). I'm sure it can be improved, but this is passing all tests reliably, it seems. Many thanks, Christian and Daniel, for your help! Best, -Andy parseDouble :: Parser Double parseDouble = try $ do (symbol toks) - n - floater return $ negate n | floater where toks = makeTokenParser emptyDef -- This could definitely be improved, but it's working. :-) floater :: Parser Double floater = do w - many1 digit char '.' f - many1 digit e - optionMaybe $ do char 'e' -- Optional exponent part n - option (char '-' return -) -- Optional negation in exponent m - many1 digit return $ n ++ m case e of Nothing - return $ read $ w ++ . ++ f Just e' - return $ read $ w ++ . ++ f ++ e ++ e' -- Andy Gimblett http://gimbo.org.uk/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Problems linking hsql-mysql
Hi, I have problems linking a simple test program that imports Database.HSQL.MySQL via ghc --make Test.hs. The error only occurs when importing this module of hsql-mysql-1.7.1. I pasted the building output here: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=22911 (actually it was even longer but hpaste only takes 30k). When I do ghc -e main Test.hs or starting it from GHCi, everything works fine and no errors occur. So I guess all needed .lib files are there but GHC can't find them when linking (adding the flag -Lpath to mysql/lib/opt doesn't help). Anyone an idea? Best wishes, Maciej ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Proper round-trip HughesPJ/Parsec for Doubles?
If you use read (reads) and show for the actual conversion it will round trip. It appears to be non-trivial since most languages and libraries get it wrong. :) -- Lennart On Tue, Feb 23, 2010 at 1:44 PM, Andy Gimblett hask...@gimbo.org.uk wrote: Hi all, Short version: How can I pretty print and parse values of type Double such that those operations are each other's inverse? Long version: I'm writing and QuickCheck-testing a parser using the approach set out here: http://lstephen.wordpress.com/2007/07/29/parsec-parser-testing-with-quickcheck/ That is, each syntactic category gets a pretty-printer and a parser and an Arbitrary instance, and QuickCheck checks that (parse . prettyPrint) == id, basically. Somewhat unsurprisingly, this sometimes fails for floating point values (I'm using Doubles). Now, I know that floats are in some sense imprecise, and comparing for equality is fraught with peril, but it seems that if x==x then it ought to be at least _possible_ to arrange matters such that (parse . prettyPrint x) == x as well. At worst, pretty-printing the underlying binary representation!? So my feeling is that my parser could be improved. At the moment I'm working around it by defining a type class which checks for equality within some margin of error, and using that instead of Eq - but it's messier than I'd like, so I wondered if there was something obvious I'm missing. As hpaste.org seems to be down, I'll attach a code example here instead. Thanks! -Andy -- Andy Gimblett http://gimbo.org.uk/ ___ 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] Re: Proper round-trip HughesPJ/Parsec for Doubles?
For the record, here's the final improved version: float' :: TokenParser st - GenParser Char st Double float' t = do n - liftCtoS '-' w - many1 digit char '.' f - many1 digit e - option $ do char 'e' n' - liftCtoS '-' m - many1 digit return $ concat [e, n', m] whiteSpace t return $ read $ concat [n, w, ., f, e] where liftCtoS a = option (char a return [a]) Thanks for all the help, again. -Andy -- Andy Gimblett http://gimbo.org.uk/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Problems linking hsql-mysql
Hi Maciej, I will try to reproduce the error -- could you send me your both *.cabal files (for hsql hsql-mysql), if you have changed anything, and your system configuration. Is this extremely urgent? I ask this, as these days exactly the end phase of the projects of about 100 beginner Haskell students, which I am the one to look after. So I am in a little of slow motion regarding other things... ;-) But in case you are in emergency, please let me know... At first sight, I would say it looks like a configuration problem... ;-) Cheers, Nick Maciej Podgurski wrote: Hi, I have problems linking a simple test program that imports Database.HSQL.MySQL via ghc --make Test.hs. The error only occurs when importing this module of hsql-mysql-1.7.1. I pasted the building output here: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=22911 (actually it was even longer but hpaste only takes 30k). When I do ghc -e main Test.hs or starting it from GHCi, everything works fine and no errors occur. So I guess all needed .lib files are there but GHC can't find them when linking (adding the flag -Lpath to mysql/lib/opt doesn't help). Anyone an idea? Best wishes, Maciej ___ 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] Re: sendfile leaking descriptors on Linux?
On Feb 21, 2010, at 20:17 , Jeremy Shaw wrote: The PS3 does do something though. If we were doing a write *and* read select on the socket, the read select would wakeup. So, it is trying to notify us that something has happened, but we are not seeing it because we are only looking at the write select(). Earlier the OP claimed this would happen within a few minutes if he seeked in a movie. If it's that reproducible, it should be easy to capture a tcpdump and attach it to an email (or pastebin it), allowing us to determine what really happens. Also, Donn, you are incorrect about invalidating premises; we know the connection is going away, we can infer it's not going away normally, that's why there have been comments about it sending a FIN and dropping the connection entirely (bypassing the shutdown handshake), or sending an RST, etc. (I'd also be interested in finding out if OpenSolaris or FreeBSD has the same problem, but that may be too difficult to test easily. I still find it highly unlikely that loss of a connection only wakes the read end in general, and would absolutely not be surprised if this were some odd corner case in the Linux TCP stack. Sadly, I don't have a PS3 (yet, if ever) and I don't know of any streaming software for non-hacked Wiis.) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: sendfile leaking descriptors on Linux?
Quoth Brandon S. Allbery KF8NH allb...@ece.cmu.edu, On Feb 21, 2010, at 20:17 , Jeremy Shaw wrote: The PS3 does do something though. If we were doing a write *and* read select on the socket, the read select would wakeup. So, it is trying to notify us that something has happened, but we are not seeing it because we are only looking at the write select(). Earlier the OP claimed this would happen within a few minutes if he seeked in a movie. If it's that reproducible, it should be easy to capture a tcpdump and attach it to an email (or pastebin it), allowing us to determine what really happens. Also, Donn, you are incorrect about invalidating premises; we know the connection is going away, we can infer it's not going away normally, that's why there have been comments about it sending a FIN and dropping the connection entirely (bypassing the shutdown handshake), or sending an RST, etc. That's what I'm saying - it clearly is not a full close, i.e., going away normally per protocol. With luck maybe the packets will show that something does happen at a wire protocol level, and there will be a way to recognize the event at the `user land' level and plug that into the event loop. My prediction is that on the contrary, the transition between functional and defunct will not be not announced in any way by the peer, but that's just guessing. It would be a lot less interesting. Donn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: sendfile leaking descriptors on Linux?
On Feb 23, 2010, at 23:47 , Donn Cave wrote: My prediction is that on the contrary, the transition between functional and defunct will not be not announced in any way by the peer, but that's just guessing. It would be a lot less interesting. But that's not the issue. The *kernel* is clearly detecting it; the problem is it's only being reported for the *read* end of the socket, whereas sendfile() (correctly) only cares about, and therefore only registers interest in, the *write* end. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimizing hash array mapped tries
On Feb 22, 2010, at 02:15 , Edward Z. Yang wrote: * i-Full-update essentially copies a 32-size vector, with a change to one element. I think I am getting brutally punished for this, in terms of both memory usage as well as runtime. What I'm curious is whether or not this is intrinsic to the algorithm, or if it's something special that GHC is doing. IIRC this is intrinsic to the way GHC modifies and garbage-collects array modifications. There's been discussion on -cafe about it. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC RTS question
On Feb 22, 2010, at 03:36 , Roman Cheplyaka wrote: * Anthony Cowley acow...@seas.upenn.edu [2010-02-21 14:15:00-0500] #! /usr/bin/env bash ./prog --RTS $* ./prog --RTS $@ Otherwise it will work wrong if arguments contain quoted field separators (e.g. spaces). #! /bin/sh ./prog --RTS ${1+$@} The longer specification above should work with whatever /bin/sh is around, whether it's Solaris /sbin/sh, FreeBSD's sh, general Linux bash, Debian/Ubuntu dash, etc. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Linux ghci vs Windows ghci
On Feb 21, 2010, at 06:27 , Donghee Nah wrote: I'm using Windows 7 32bit Host OS(ghc 6.8.3) and Virtualbox Archlinux Guest OS(ghc 6.8.4) I feel that ghci code executing speed in guest os is 1.5~2x faster than host os My guess is that GHC (and the GHC RTS) on win32 is using a POSIX emulation layer supplied by mingw32 for all system calls, introducing extra overhead. Unfortunately, I don't think we have enough Windows- familiar folks with enough understanding of the GHC RTS to optimize it for the native Windows API. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] [offtopic] UNIX Shell (was: GHC RTS question)
* Brandon S. Allbery KF8NH allb...@ece.cmu.edu [2010-02-24 00:02:12-0500] On Feb 22, 2010, at 03:36 , Roman Cheplyaka wrote: * Anthony Cowley acow...@seas.upenn.edu [2010-02-21 14:15:00-0500] #! /usr/bin/env bash ./prog --RTS $* ./prog --RTS $@ Otherwise it will work wrong if arguments contain quoted field separators (e.g. spaces). #! /bin/sh ./prog --RTS ${1+$@} The longer specification above should work with whatever /bin/sh is around, whether it's Solaris /sbin/sh, FreeBSD's sh, general Linux bash, Debian/Ubuntu dash, etc. Are you referring to some Solaris shell bug? Under POSIX these constructs seem to be equivalent. If there are no positional parameters, the expansion of '@' shall generate zero fields, even when '@' is double-quoted. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe