[Haskell-cafe] Re: What does the Haskell type system do with "show (1+2)"?

Christian Maeder maeder at tzi.de
Fri Jan 13 05:12:08 EST 2006


Jared Updike wrote:
> http://www.haskell.org/onlinereport/decls.html#default-decls
> http://www.haskell.org/tutorial/numbers.html#sect10.4

I still don't see, why it works for show but not for my_show.

> On 1/12/06, Jeff.Harper at handheld.com <Jeff.Harper at handheld.com> wrote:
[...]
>> class (Show a) => My_show a where
>>    my_show :: a -> String

If I let this be

   class My_show a where
       my_show :: a -> String

>> instance My_show Int where
>>    my_show a = show a ++ " :: Int"
>>
>> instance My_show Integer where
>>    my_show a = show a ++ " :: Integer"

What is the difference to the builtin Show class?

Christian


More information about the Haskell-Cafe mailing list