Re: [Haskell-cafe] Mystery of an Eq instance

2013-09-21 Thread damodar kulkarni
Making floats not be an instance of Eq will just cause those people to ask Why can't I compare floats for equality?. This will lead to pretty much the same explanation. Yes, and then all the torrent of explanation I got here about the intricacies of floating point operations would seem more

Re: [Haskell-cafe] Mystery of an Eq instance

2013-09-21 Thread Bardur Arantsson
On 2013-09-21 06:16, Mike Meyer wrote: The single biggest gotcha is that two calculations we expect to be equal often aren't. As a result of this, we warn people not to do equality comparison on floats. The Eq instance for Float violates at least one expected law of Eq: Prelude let nan =

Re: [Haskell-cafe] Mystery of an Eq instance

2013-09-21 Thread Stijn van Drongelen
I think you are trying to solve a problem that doesn't exist. * Float and Double are imprecise types by their very nature. That's exactly what people are forgetting, and exactly what's causing misunderstandings. Perhaps(!) it would be better to remove the option to use rational literals as

Re: [Haskell-cafe] Mystery of an Eq instance

2013-09-21 Thread Colin Adams
On 21 September 2013 08:34, Stijn van Drongelen rhym...@gmail.com wrote: * As mentioned, there is a total order (Ord) on floats (which is what you should be using when checking whether two approximations are approximately equal), which implies that there is also an equivalence relation (Eq).

Re: [Haskell-cafe] Mystery of an Eq instance

2013-09-21 Thread Stijn van Drongelen
On Sep 21, 2013 9:38 AM, Colin Adams colinpaulad...@gmail.com wrote: On 21 September 2013 08:34, Stijn van Drongelen rhym...@gmail.com wrote: * As mentioned, there is a total order (Ord) on floats (which is what you should be using when checking whether two approximations are approximately

Re: [Haskell-cafe] Mystery of an Eq instance

2013-09-21 Thread Mike Meyer
On Sat, Sep 21, 2013 at 2:21 AM, Bardur Arantsson s...@scientician.net wrote: On 2013-09-21 06:16, Mike Meyer wrote: The single biggest gotcha is that two calculations we expect to be equal often aren't. As a result of this, we warn people not to do equality comparison on floats. The Eq

Re: [Haskell-cafe] Mystery of an Eq instance

2013-09-21 Thread Stijn van Drongelen
On Sat, Sep 21, 2013 at 10:26 AM, Mike Meyer m...@mired.org wrote: On Sat, Sep 21, 2013 at 2:21 AM, Bardur Arantsson s...@scientician.net wrote: On 2013-09-21 06:16, Mike Meyer wrote: The single biggest gotcha is that two calculations we expect to be equal often aren't. As a result of

[Haskell-cafe] Problem with HXT `when`

2013-09-21 Thread Vlatko Basic
Hello Cafe, I have this HTML structure: ... table ... tr thCaption/th td a href=...Want this/a a href=...And this/a /td /tr tr thAnother caption/th td tr thYet another

[Haskell-cafe] using default declaration for overloaded numeric operations

2013-09-21 Thread TP
Hi, I try to develop an embedded domain specific language in Haskell. I don't want to type ::Rational all the time, so I try to use a default declaration for my types. This works correctly in this simple example: -- default (Integer, Double) -- default

Re: [Haskell-cafe] ANNOUNCE: New OpenGL packages

2013-09-21 Thread Ivan Perez
Thank you very much for the work. It is deeply appreciated. I'll test all of Keera's programs with these new versions and let you know if something comes up. Best regards Ivan On 15 September 2013 18:23, Sven Panne svenpa...@gmail.com wrote: New versions of the OpenGL packages are available

Re: [Haskell-cafe] Mystery of an Eq instance

2013-09-21 Thread Bob Hutchison
On 2013-09-21, at 4:46 AM, Stijn van Drongelen rhym...@gmail.com wrote: I do have to agree with Damodar Kulkarni that different laws imply different classes. However, this will break **a lot** of existing software. You could argue that the existing software is already broken. If we would

[Haskell-cafe] type-level integers, type-level operators, and most specific overlapping instance

2013-09-21 Thread TP
Hi everybody, I encouter some problem in my code in the following simple example: two instances overlap for the multiplication sign `*`. The `OverlappingInstances` extension is of no help because it seems GHC does not look at the instance context to decide which instance is the most specific.

Re: [Haskell-cafe] type-level integers, type-level operators, and most specific overlapping instance

2013-09-21 Thread adam vogt
Hi TP, You can add another instance to cover the case that everything is zero. Then you don't need the :. Also it's convenient to arrange for the a,b,c to be the argument to Tensor, as given below: class Multiplication a b c | a b - c where (*) :: Tensor a - Tensor b - Tensor c instance

Re: [Haskell-cafe] Mystery of an Eq instance

2013-09-21 Thread Stijn van Drongelen
On Sep 21, 2013 4:17 PM, Bob Hutchison hutch-li...@recursive.ca wrote: On 2013-09-21, at 4:46 AM, Stijn van Drongelen rhym...@gmail.com wrote: I do have to agree with Damodar Kulkarni that different laws imply different classes. However, this will break **a lot** of existing software. You

Re: [Haskell-cafe] Mystery of an Eq instance

2013-09-21 Thread Stuart A. Kurtz
Let me quibble. * Float and Double are imprecise types by their very nature. That's exactly what people are forgetting, and exactly what's causing misunderstandings. Float and Double are precise types. What is imprecise is the correspondence between finite precision floating point types

Re: [Haskell-cafe] type-level integers, type-level operators, and most specific overlapping instance

2013-09-21 Thread TP
adam vogt wrote: You can add another instance to cover the case that everything is zero. Then you don't need the :. Also it's convenient to arrange for the a,b,c to be the argument to Tensor, as given below: class Multiplication a b c | a b - c where (*) :: Tensor a - Tensor b - Tensor

Re: [Haskell-cafe] Mystery of an Eq instance

2013-09-21 Thread Bardur Arantsson
On 2013-09-20 18:31, Brandon Allbery wrote: [--snip--] unless you have a very clever representation that can store in terms of some operation like sin(x) or ln(x).) I may just be hallucinating, but I think this is called describable numbers, i.e. numbers which can described by some (finite)

Re: [Haskell-cafe] Mystery of an Eq instance

2013-09-21 Thread Brandon Allbery
On Sat, Sep 21, 2013 at 12:35 PM, Bardur Arantsson s...@scientician.netwrote: On 2013-09-20 18:31, Brandon Allbery wrote: [--snip--] unless you have a very clever representation that can store in terms of some operation like sin(x) or ln(x).) I may just be hallucinating, but I think this

Re: [Haskell-cafe] Mystery of an Eq instance

2013-09-21 Thread David Thomas
Sure. An interesting, if not terribly relevant, fact is that there are more irrational numbers that we *can't* represent the above way than that we can (IIRC). However, those aren't actually interesting in solving the kinds of problems we want to solve with a programming language, so it's

Re: [Haskell-cafe] Mystery of an Eq instance

2013-09-21 Thread Brandon Allbery
On Sat, Sep 21, 2013 at 12:43 PM, David Thomas davidleotho...@gmail.comwrote: Sure. An interesting, if not terribly relevant, fact is that there are more irrational numbers that we *can't* represent the above way than that we can (IIRC). I think that kinda follows from diagonalization... it

Re: [Haskell-cafe] Mystery of an Eq instance

2013-09-21 Thread David Thomas
I think that's right, yeah. On Sat, Sep 21, 2013 at 9:49 AM, Brandon Allbery allber...@gmail.comwrote: On Sat, Sep 21, 2013 at 12:43 PM, David Thomas davidleotho...@gmail.comwrote: Sure. An interesting, if not terribly relevant, fact is that there are more irrational numbers that we

Re: [Haskell-cafe] Mystery of an Eq instance

2013-09-21 Thread Mike Meyer
On Sep 21, 2013 9:17 AM, Bob Hutchison hutch-li...@recursive.ca wrote: On 2013-09-21, at 4:46 AM, Stijn van Drongelen rhym...@gmail.com wrote: I do have to agree with Damodar Kulkarni that different laws imply different classes. However, this will break **a lot** of existing software. You could

Re: [Haskell-cafe] Mystery of an Eq instance

2013-09-21 Thread Bardur Arantsson
On 2013-09-21 23:08, Mike Meyer wrote: Exactly. The Eq and Ord instances aren't what's broken, at least when you're dealing with numbers (NaNs are another story). That there are pairs According to Haskell NaN *is* a number. Eq and Ord are just the messengers. No. When we declare something an

Re: [Haskell-cafe] Mystery of an Eq instance

2013-09-21 Thread Mike Meyer
On Sat, Sep 21, 2013 at 5:28 PM, Bardur Arantsson s...@scientician.net wrote: On 2013-09-21 23:08, Mike Meyer wrote: Exactly. The Eq and Ord instances aren't what's broken, at least when you're dealing with numbers (NaNs are another story). That there are pairs According to Haskell NaN *is*

[Haskell-cafe] Strange exit status behavior from the process package

2013-09-21 Thread Michael Xavier
I've run into some strangeness with the process package. When you kill some processes on the command line you correctly get a non-zero exit status. However when using the process package's terminateProcess (which sends a SIGTERM), it returns an ExitSuccess: module Main (main) where import

Re: [Haskell-cafe] Mystery of an Eq instance

2013-09-21 Thread Carter Schonwald
i had a longer email written out, but decided a shorter one is better. I warmly point folks to use libs like the numbers package on hackage http://hackage.haskell.org/packages/archive/numbers/2009.8.9/doc/html/Data-Number-BigFloat.html it has some great alternatives to standard floats and

[Haskell-cafe] Creating a local Hoogle ...

2013-09-21 Thread aditya siram
Hi all, I've installed Hoogle but am having issues creating the databases. I first did: `hoogle data all`, tried a search `hoogle [a] - a and got: Could not find some databases: default Searching in: . ~/.cabal/share/hoogle-4.2.21/databases Either the package does not exist or has not been

Re: [Haskell-cafe] Strange exit status behavior from the process package

2013-09-21 Thread Brandon Allbery
On Sat, Sep 21, 2013 at 11:12 PM, Michael Xavier mich...@michaelxavier.netwrote: I've run into some strangeness with the process package. When you kill some processes on the command line you correctly get a non-zero exit status. However when using the process package's terminateProcess (which