default instance for IsString

Ozgur Akgun ozgurakgun at gmail.com
Wed Apr 25 11:39:12 CEST 2012


One can always use a Maybe to make an IsString literal total. Perhaps this
is what library authors should do in those cases when a fromString
implementation is obviously partial.

i.e. instead of instance IsString XML where ...
define: instance IsString (Maybe XML) where ...

HTH,
Ozgur

On 24 April 2012 15:03, Yitzchak Gale <gale at sefer.org> wrote:

> Daniel Peebles wrote:
> > Why are potentially partial literals scarier than the fact that every
> value
> > in the language could lead to an exception when forced?
>
> That's a legitimate question, but it's strange to hear it from
> you.
>
> People ask that same question about Haskell's static
> type system. Why bother? Every value could lead to an
> exception when forced. So we might as well check
> everything at run time.
>
> Wouldn't it be ironic if the one thing that every language
> other than Haskell is able to check at compile time,
> namely the static syntax of string literals, could only be
> checked at run time in Haskell? Especially when, with just
> a little care, we could easily continue to check it at compile
> time while still supporting string literals of type Text
> and ByteString.
>
> I guess I'm just not understanding your question.
>
> Thanks,
> Yitz
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20120425/b9114062/attachment.htm>


More information about the Glasgow-haskell-users mailing list