default instance for IsString

Yitzchak Gale gale at
Tue Apr 24 09:58:47 CEST 2012

Markus Läll wrote:
> What can go wrong when you use an overloaded string to be fromString'd
> into Text?

Here's an example:

The author of the xml-types package provides an IsString
instance for XML names, so you can conveniently
represent XML names as string literals in your source

But not every string is a valid XML name. If you mistype
the literal, your program will still compile. It may even run
for a while. But when someone uses your program in
a way that causes that mistyped XML name literal
to be resolved, your program will likely crash, unless you
structured it in a way that allows that XML name literal
to be wrapped in an appropriate exception handler in the
IO monad.


More information about the Glasgow-haskell-users mailing list