Hello,
I have this code:
class C a b c | a b -> c where
f :: a -> b -> c
instance C a b c => C a (x,y,b) c where
f a (_,_,b) = f a b
instance C a (a,c,b) c where
f _ (_,c,_) = c
ghci -fglasgow-exts -fallow-overlapping-instances compiles it without
complaint b
G'day all.
On Sat, Aug 09, 2003 at 01:32:49AM +0200, Wolfgang Jeltsch wrote:
> ghci -fglasgow-exts -fallow-overlapping-instances compiles it without
> complaint
If it helps, ghci will complain the first time you actually try to use
it.
Cheers,
Andrew Bromage
___
Behalf Of Wolfgang Jeltsch
> Sent: Friday, August 08, 2003 4:33 PM
> To: The Haskell Mailing List
> Subject: overlapping instances and functional dependencies
>
>
> Hello,
>
> I have this code:
> class C a b c | a b -> c where
> f :: a -> b -> c
&g
I wrote on Saturday, 2003-08-09, 01:32, CEST:
> Hello,
>
> I have this code:
> class C a b c | a b -> c where
> f :: a -> b -> c
>
> instance C a b c => C a (x,y,b) c where
> f a (_,_,b) = f a b
>
> instance C a (a,c,b) c where
> f _ (_,c,_) = c
> ghci -fglasgow-
Hello,
I think, I realized now what my mistake was. The handling of overlapping
instances comes into play when the compiler has to decide which method
definition to choose for a specific instance. It is not for choosing one of
more possible instances.
In my example, C Int (Int,Char,Bool) Int a
Wolfgang Jeltsch has observed:
> I have this code:
> class C a b c | a b -> c where
> f :: a -> b -> c
>
> instance C a b c => C a (x,y,b) c where
> f a (_,_,b) = f a b
>
> instance C a (a,c,b) c where
> f _ (_,c,_) = c
> ghci -fglasgow-exts -fallow-overlapping-
Hi all
With overlapping instances, I'm allowed
class OK x y
instance Functor f => OK (f x) (f y)
instance Functor f => OK x (f y)
but I'm not allowed
class Bad x y z | x y -> z
instance Functor f => Bad (f x) (f y) Bool
instance Functor f => Bad x (f y) Int
I don't quite see wh
C T McBride writes:
:
| but I'm not allowed
|
| class Bad x y z | x y -> z
|
| instance Functor f => Bad (f x) (f y) Bool
|
| instance Functor f => Bad x (f y) Int
|
| I don't quite see why. Naively, I imagine that if the OK instances are
| effectively prioritized, then Bad's r
| class C a b c | a b -> c where
| f :: a -> b -> c
|
| instance C a b c => C a (x,y,b) c where
| f a (_,_,b) = f a b
|
| instance C a (a,c,b) c where
| f _ (_,c,_) = c
| ghci -fglasgow-exts -fallow-overlapping-instances compiles it without
| complaint but hug
| With overlapping instances, I'm allowed
|
| class OK x y
|
| instance Functor f => OK (f x) (f y)
|
| instance Functor f => OK x (f y)
|
| but I'm not allowed
|
| class Bad x y z | x y -> z
|
| instance Functor f => Bad (f x) (f y) Bool
|
| instance Functor f => Bad x (f y) Int
10 matches
Mail list logo