Proposal: Improving the IsString String instance
Henning Thielemann
schlepptop at henning-thielemann.de
Mon Aug 26 19:10:27 CEST 2013
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.
More information about the Libraries
mailing list