
Little by little, I think I am getting closer. class Show a => Visible a where toString :: a -> String toString = show size :: a -> Int size = length . show Is just declaration, not definition. It doesn't define anything, even though it has default implementations for toString and size one still needs to define instance of it. Right? As Sebastian Sylvan proposed, I probably need something like this: class Visible a where toString :: a -> String size :: a -> Int instance Show a => Visible a where toString = show size = length . show But it seems ghc doesn't like instance definitions like 'instance Show a => Visible a where ...'. Why? -- Slavomir Kaslev

Hello Slavomir, Thursday, November 2, 2006, 5:47:37 PM, you wrote:
class Show a => Visible a where toString :: a -> String toString = show size :: a -> Int size = length . show
it's not that you need. it's definition of subclass, say class Set a => OrderedSet a -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com
participants (2)
-
Bulat Ziganshin
-
Slavomir Kaslev