On Sun, 26 Jun 2005, Daniel Fischer wrote: > Am Samstag, 25. Juni 2005 21:22 schrieb Josh Hoyt: > > Hello, > > > > I'm a new Haskeller, and I'm running into a problem attempting to > > declare certain types as instances. I was attempting something that's > > > > effectively equivalent to: > > > class Foo a > > > > > > instance Foo (Either b b) > > > > My question is, why this restriction that the types must be distinct? > > > > In particular, I'd like to declare a very specific type (Either String > > String) as an instance. What techniques can I use to accomplish this? > > > > Josh Hoyt > > I don't know, why the tyvars must be distinct in Haskell 98,
This is certainly to prevent from overlapping instances. An implementation for general (Either a b) could also be invoked when (Either String String) is requested. If it is really necessary to make the Either type an instance of something better use a data or a newtype definition. newtype EitherString = EitherString (Either String String) and declare an instance for EitherString. _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
