Problem with functional dependencies

2007-11-16 Thread Daniel Gorín
Hi I have some code that uses MPTC + FDs + flexible and undecidable instances that was working fine until I did a trivial modification on another part of the project. Now, GHC is complaining with a very confusing (for me, at least) error message. I've been finally able to reproduce the

Re: Problem with functional dependencies

2007-11-16 Thread Chris Kuklewicz
I have a guess... Daniel Gorín wrote: Hi I have some code that uses MPTC + FDs + flexible and undecidable instances that was working fine until I did a trivial modification on another part of the project. Now, GHC is complaining with a very confusing (for me, at least) error message. I've

Re: Problem with functional dependencies

2007-11-16 Thread Chris Kuklewicz
By the way, if you make the class C fundep declaration into: class C m f n | m f - n where then it compiles. This means ((M n) and (F n) imply N) and (any m and F' imply N') which no longer conflict. Daniel Gorín wrote: Hi I have some code that uses MPTC + FDs + flexible and undecidable

Re: Problem with functional dependencies

2007-11-16 Thread Daniel Gorín
Hi, Chris Thanks for your answer. I guess that my intuitions of what functional dependencies and context meant were not very accurate (see below) class C m f n | m - n, f - n where c :: m - f - Bool The m-n functional dependency means that I tell you C x _ z is an instance then you

RE: Problem with functional dependencies

2001-01-04 Thread Mark P Jones
Hi Marcin, | In particular, should the following be legal: | | class C a b c | a - b c | instance C [a] b b | f:: C [a] b c = a | f = undefined | | ghc panics and Hugs rejects it. No, it is not legal. Even if you delete the definition of f, the code is still not legal because the class and

Re: Problem with functional dependencies

2001-01-04 Thread Marcin 'Qrczak' Kowalczyk
Thu, 4 Jan 2001 13:01:56 -0800, Mark P Jones [EMAIL PROTECTED] pisze: I hope now that the problem is becoming clear: this instance declaration is not consistent with the dependency; in the first two lines above, for example, we see two rows that violate the specification because they have

RE: Problem with functional dependencies

2001-01-03 Thread Mark P Jones
| I think you can simplify the example. Given | | class HasFoo a b | a - b where | foo :: a - b | instance HasFoo Int Bool where ... | | Is this legal? | f :: HasFoo Int b = Int - b | f x = foo x The theoretical foundation for functional dependencies goes back

Re: Problem with functional dependencies

2001-01-03 Thread Fergus Henderson
On 03-Jan-2001, Mark P Jones [EMAIL PROTECTED] wrote: ... the best way to deal with this is (probably): (i) to infer simpler types whenever possible, but (ii) to allow more polymorphic types when they are requested by means of an explicit type signature. I agree. (Incidentally, in

Re: Problem with functional dependencies

2001-01-03 Thread Marcin 'Qrczak' Kowalczyk
I don't fully understand fundeps. Would the following transform legal programs (without overlapping instances) into legal programs? I hope yes. Let's imagine a class with a set of instances and uses, without fundeps. - Add some additional type variables to the class header. - Add a fundep: all

Re: Problem with functional dependencies

2000-12-21 Thread Jeffrey R. Lewis
Simon Peyton-Jones wrote: I think you can simplify the example. Given class HasFoo a b | a - b where foo :: a - b instance HasFoo Int Bool where ... Is this legal? f :: HasFoo Int b = Int - b f x = foo x You might think so, since

Re: Problem with functional dependencies

2000-12-21 Thread Marcin 'Qrczak' Kowalczyk
Thu, 21 Dec 2000 00:59:29 -0800, Jeffrey R. Lewis [EMAIL PROTECTED] pisze: class HasFoo a b | a - b where f :: HasFoo Int b = Int - b f x = foo x This is the step where the reasoning goes wrong. The functional dependency tells you that `b' isn't really a free

Re: Problem with functional dependencies

2000-12-21 Thread Lennart Augustsson
Simon Peyton-Jones wrote: I think you can simplify the example. Given class HasFoo a b | a - b where foo :: a - b instance HasFoo Int Bool where ... Is this legal? f :: HasFoo Int b = Int - b f x = foo x You might think so, since

RE: Problem with functional dependencies

2000-12-20 Thread Simon Peyton-Jones
than meets the eye. Even whether one type is more general than another has changed! Simon | -Original Message- | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] | Sent: 17 December 2000 19:30 | To: [EMAIL PROTECTED] | Subject: Problem with functional dependencies | | | The follow

Problem with functional dependencies

2000-12-17 Thread Marcin 'Qrczak' Kowalczyk
The following module is rejected by both ghc -fglasgow-exts -fallow-undecidable-instances and hugs -98 class HasFoo a foo | a - foo where foo :: a - foo data A = A Int data B = B A instance HasFoo A Int where