On Dec 25, 2007 12:11 AM, Konstantin Vladimirov <[EMAIL PROTECTED]> wrote: > > class FirstClass a where > firstFunction :: (SecondClass b) => a -> b >
<snip!> > > instance FirstClass FirstData where > firstFunction (FirstData d) = SecondData d The problem is that the type of firstFunction as producing a result of type 'b', where 'b' is *any* type inahbiting the typeclass "SecondClass." Your definition of firstFunction can produce only *one* of the inhabitants of "SecondClass". You'd think this would be okay, seeing as there is only one member of the typeclass, but because anyone can come along and add a new typeclass instance, you're definition of "firstFunction" needs to account for that. If you're type-classes only ever have one instance, maybe it's easier to not use them, and go with: > convert :: FirstData -> SecondData > convert (FirstData d) = SecondData d But I'm not sure if that suggestion is at all helpful. -Antoine _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe