Re: Defaults for superclass methods

14 Apr
2006
14 Apr
'06
3:44 p.m.
On 14/04/06, Dave Menendez
The tricky part is dealing with multiple subclasses.
For example,
class Functor f where fmap :: (a -> b) -> f a -> f b
class Functor f => Monad f where ... fmap = liftM
class Functor f => Comonad f where ... fmap = liftW
newtype Id a = Id a
instance Functor Id instance Monad Id instance Comonad Id
Which default gets used for fmap?
The simple solution is to make it an error, and force the programmer to define an instance of Functor as soon as that happens. Most of the problems seem to happen in mostly-linear hierarchies anyway.
7026
Age (days ago)
7026
Last active (days ago)
0 comments
1 participants
participants (1)
-
Cale Gibbard