[Haskell-cafe] Reverse Show instance

Markus Läll markus.l2ll at gmail.com
Thu May 19 23:26:16 CEST 2011


If you have nested type, then it usually makes sense to have Show defined
for the inside types, too, but it's not a requirement. Technically, only
when you call 'show' for something in the data type you are defining Show
for, *then* you need a Show instance defined for that inside-type.

On Fri, May 20, 2011 at 12:15 AM, Andrew Coppin <andrewcoppin at btinternet.com
> wrote:

> On 19/05/2011 10:11 PM, Artyom Kazak wrote:
>
>> And I can declare an instance for (x, y) which does NOT implies (Show x):
>>
>> instance Show (x, y) where
>> show _ = "I'm tuple! Hooray!"
>>
>
> Ah. So it's a feature.
>
> Fortunately I refactored the program where this came up, so it's no longer
> an issue. I just wanted to see whether or not it was a bug.
>
> PS. Wouldn't such an instance require FlexibleContexts or something?
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
Markus Läll
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110520/4ee08c0c/attachment.htm>


More information about the Haskell-Cafe mailing list