You might also wish to look at the typed heaps, which have been
discussed here on many occasions. Given the constant piece of code in
the appendix (which does *not* depend on user types and can be put
into a separate, constant module) you can write
> data Gender = Masc | Fem | Neutr deriving (S
| 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
| 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
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
Yes, this is essentially what DynamicMap isThe url i posted before
was wrong...it should have been:
www.isi.edu/~hdaume/haskell/DynamicMap.hs
--
Hal Daume III | [EMAIL PROTECTED]
"Arrest this man, he talks in maths." | www.isi.edu/~hdaume
> -
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
After taking a look at Data.Dynamic I came up with:
> data Gender = Masc | Fem | Neutr deriving (Typeable, Show)
> data Number = First | Second | Third deriving (Typeable, Show)
>
> type Attrs = [Dynamic]
>
> attrs = [toDyn Masc, toDyn Second]
>
> gattr :: (Typeable a) => Attrs -> Maybe a