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
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
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
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
| 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
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,
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
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 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
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
10 matches
Mail list logo