[Haskell-cafe] Factoring into type classes

Holger Siegel holgersiegel74 at yahoo.de
Mon Jan 19 08:49:58 EST 2009


Am Montag, den 19.01.2009, 14:47 +0100 schrieb Daniel Fischer:
> Am Montag, 19. Januar 2009 14:31 schrieb Antoine Latter:
> > 2009/1/19 Luke Palmer <lrpalmer at gmail.com>:
> > > As a side curiosity, I would love to see an example of any data structure
> > > which has more than one Functor instance.  Especially those which have
> > > more than one useful functor instance.
> >
> > (,)  ?
> >
> > -Antoine
> 
> Wrong kind. And 
> (,) a
> has only one useful instance.


What about

instance Functor ((,) a) where
        fmap f (x,y) = (x, f y)

and

instance Functor (, a) where
        fmap f (x, y) = (f x, y)

? Of course, the latter is not legal Haskell. But if it was, then it
might be useful.

Is there any way to declare this Functor instance, possibly with some
GHC extensions?





More information about the Haskell-Cafe mailing list