I think Henning's suggestion makes a lot of sense.  It's syntactically light-weight, requires *no* special compiler or language support, and is quite flexible, being available per-use instead of per-module as is the case for OverloadedStrings.  The only drawback I see (and it's a moderately big one) is that there appears to already be a lot of inertia towards OverloadedStrings, and this would require yet another shift in the Haskell ecosystem.  That and the possibility of identifier clashes, of course...




On Mon, Aug 26, 2013 at 12:19 PM, Gabriel Gonzalez <gabriel439@gmail.com> wrote:
I think Henning has a point regarding defining:

    o = fromString

All these libraries that Edward mentions already ask the user to paste a lot of boilerplate at the top of their module consisting of various extensions and imports.  Why not simply remove the `OverloadedString`s pragma from the boilerplate and replace it with `o = fromString` and get almost the exact same benefits?



On Mon, Aug 26, 2013 at 10:10 AM, Henning Thielemann <schlepptop@henning-thielemann.de> wrote:
Am 26.08.2013 19:03, schrieb Gabriel Gonzalez:

May I propose an alternative solution?  Why not just add a syntactic way
to selectively opt in or out of `OverloadedStrings` for certain string
literals?  It could be something as simple as Python's trick for
prefixing string literals with a single character to either enable or
disable the overloading:

     example1 :: Int
     example1 = length "Non-overloaded string"

     example2 :: Parser Int
     example2 = o"Overloaded string" *> pure 4

... but it doesn't have to be that specific solution.  All that really
matters is that it is syntactically lightweight.

This "opting in" already exists: Just put a space between o and the quotation mark and define "o = fromString". It's Haskell 98.

I would prefer that solution to all syntactic extension experiments.



_______________________________________________
Libraries mailing list
Libraries@haskell.org
http://www.haskell.org/mailman/listinfo/libraries