#5255: String literals cause runtime crashes when OverloadedStrings is in effect
---------------------------------+------------------------------------------
    Reporter:  YitzGale          |        Owner:              
        Type:  feature request   |       Status:  new         
    Priority:  normal            |    Milestone:              
   Component:  Compiler          |      Version:  7.0.3       
    Keywords:                    |     Testcase:              
   Blockedby:                    |   Difficulty:              
          Os:  Unknown/Multiple  |     Blocking:              
Architecture:  Unknown/Multiple  |      Failure:  None/Unknown
---------------------------------+------------------------------------------

Comment(by snoyberg):

 Replying to [comment:8 simonpj]:
 > I'm having trouble following the details of this discussion; some
 examples would help.
 >
 > As I understand it, what you want is to be able to write the Haskell
 expression
 > {{{
 >  "<foo>mumble</blah>" :: XML
 > }}}
 > and have a ''compile-time'' error saying that the string is ill-formed.
 Is that right.
 >
 > If so, the solution is to hand, in the form of quasi-quotation
 ([http://www.haskell.org/ghc/docs/7.0-latest/html/users_guide/template-
 haskell.html#th-quasiquotation]), Geoff Mainland's enhancement to Template
 Haskell.  You say
 > {{{
 >   [xml| <foo>mumble</blah> |]
 > }}}

 We're not using IsString for the XML datatype, but rather for the Name
 datatype. An element or attribute name is composed of a local name, a
 namespace and a prefix, resulting in the datatype:

 {{{
 data Name = Name { local :: Text, namespace :: Maybe Text, prefix :: Maybe
 Text }
 }}}

 The idea of the current IsString instance for Name is to be able to encode
 both the namespace and the local name simultaneously, via "clark
 notation." In other words, "foo" => Name "foo" Nothing Nothing, and
 "{bar}foo" => Name "foo" (Just "bar") Nothing. The problem arises when the
 programmer enters the string literal "{barfoo", which currently errors
 out.

 The reason we'd like to avoid using a quasi-quoter is that it's simply
 much bigger syntax overhead than a string literal. My code base makes use
 of the IsString instance all over the place, and having to turn "{bar}foo"
 into [name|{bar}foo|] everywhere would just be inconvenient.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5255#comment:11>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to