Add instance IsString ShowS where fromString = showString

Sittampalam, Ganesh ganesh.sittampalam at
Mon Oct 5 05:42:03 EDT 2009

Bas van Dijk wrote:
> Hello,
> It would be really nice to use OverloadedStrings when constructing a
> ShowS, for example in a definition of showsPrec in an instance for
> Show.  
> The patch attached in the ticket[3544] adds the necessary instance to
> base/GHC/Show.lhs:
> instance IsString ShowS where
>     fromString = showString
> Note that this does require TypeSynonymInstances.

-1 : I don't think it's appropriate to use a type synonym instance in a
standard library.

A concrete example of the problems this would cause is that it would
interfere with any generic function instance for IsString, e.g.

instance IsString b => IsString (a -> b) where
    fromString = const . fromString

I am not suggesting that such an instance is generally useful, but
people who wanted to use it in their own private code would be
obstructed from doing so by an instance for (String -> String).



 Please access the attached hyperlink for an important electronic communications disclaimer: 

More information about the Libraries mailing list