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 ha

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-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 o

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. > (Incidental

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 ba

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,

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 rea

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,

RE: Problem with functional dependencies

2000-12-20 Thread Simon Peyton-Jones
re here, but there's more to this functional dependency stuff 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] | S

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