default instance for IsString
pumpkingod at gmail.com
Tue Apr 24 20:19:10 CEST 2012
I think my point was more along the lines that every *value*, regardless of
whether it's a function or not, can be partial (ignoring primitive types
and such). I can hand you a list where the third Int in it will cause you
to crash if you force it.
In that sense, whether every numeric literal expands to fromInteger ... or
every string literal expands to fromString ... doesn't really make it any
different from any other value. Is the concern that because it's
polymorphic, that different uses of the "same" polymorphic value might or
might not crash? That's the case for any polymorphic value: take e.g., read
"()", which will crash or not depending on where it's used. If it's just
the case that the value itself could crash when forced, well, that's true
of any value of any lifted type.
So if every value, when forced, can crash your program, possibly depending
on what type it's instantiated to, why are we so concerned about String
literals behaving like everything else?
On Tue, Apr 24, 2012 at 1:23 PM, Evan Laforge <qdunkan at gmail.com> wrote:
> From what I can see the core of the disagreement is that some people
> believe fromString will tempt misuse (i.e. using *easily* partial
> functions, like XML validation), while others don't think it's that
> likely. Indeed misusing IsString is worse than your average partial
> function because of the global nature of typeclasses and fromString
> being implicit. If that is indeed the core of the disagreement, then
> can we at least agree that writing a partial fromString is a bad idea?
> I'd say *easily* partial since someone pointed out the UTF8
> fromString is partial, but it's pretty hard to type bad UTF8
> accidentally so it doesn't seem so bad to me.
> If we agree that 'fromString :: String -> XML' is a bad idea, then can
> we just say "so don't do that then"? Safety is good but there's a
> point where you have to trust people with the sharp tools. Suppose a
> library author adding a fromString for regexes that crashes on
> unbalanced parens. If it's a problem in practice I imagine people
> would complain to them to change their library, or use another
> On Tue, Apr 24, 2012 at 9:10 AM, Henrik Nilsson <nhn at cs.nott.ac.uk> wrote:
> > Hi,
> > Yitzhack Gale wrote:
> >> 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?
> > I don't really see the irony, I'm afraid, as nothing really
> > has changed, and as Simon M. that I don't see what the
> > fuss is about.
> > Presumably, the syntax of string literals as such is still going to be
> > checked by the scanner, as it always was? And the issue, then, is
> > whether an overloaded "fromString" is total in all its overloadings?
> > Or did I miss something central, here?
> > Well, Haskell is not a total language, so the fact that "fromString"
> > might have non-total overloadings is not surprising. Yes,
> > "fromString" would be implicitly inserted, just like e.g. "fromInteger"
> > for overloaded integer literals, to create the effect of overloaded
> > literals, but this is really just a convenience, albeit an important
> > one.
> > The benefit of an approach to overloading of string literals that is
> > analogous to the existing method for overloading of numeric literals
> > would seem to me to outweigh the benefits of additional static
> > checking through an essentially new approach to overloading of literals
> > for a specific case.
> > Best,
> > /Henrik
> > --
> > Henrik Nilsson
> > School of Computer Science
> > The University of Nottingham
> > nhn at cs.nott.ac.uk
> > _______________________________________________
> > Glasgow-haskell-users mailing list
> > Glasgow-haskell-users at haskell.org
> > http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Glasgow-haskell-users