[Haskell] Re: Parameterized Show
Keean Schupke
k.schupke at imperial.ac.uk
Mon Nov 15 07:31:33 EST 2004
Easy:
data ShowHex a
instance Show (ShowHex a) where
showsPrec _ (ShowHex a) = showHex a
main = putStrLn $ (show (ShowHex 27))
Here, with labelled instances you would write:
show ShowHex 27
instead you write:
show (ShowHex 27)
Keean.
George Russell wrote:
> Keean Schupke wrote:
>
>> Do you need a language extension at all? You can certainly
>> do it with the existing extensions!
>>
>> data ShowDict a
>> instance Show (ShowDict a) where
>> showsPrec _ (ShowDict a) = ...
>
>
> I don't understand. How does that help you to, for example, use a
> function which
> requires Show Int but (say) substitute the standard function for which
> which shows
> in hexadecimal?
>
> _______________________________________________
> Haskell mailing list
> Haskell at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell
More information about the Haskell
mailing list