I was wondering if anyone's thought of overloading string literals in the
same way that numeric literals are overloaded.  I know that I tend to use
PackedStrings for almost everything, primarly due to the RegExp stuff and
efficiency.  This means my code is littered with "unpackPS" and
"packString", as in

   ... if foo == packString "bar" ...

or

   ... if unpackPS foo == "bar" ...

I was wondering if someone might consider overloading Strings,
too.  Something like:

class StringLiteral s where
    fromString :: String -> s
    toString :: s -> String -- not necessary, really

then literals in haskell source could be converted from

   ... "foo" ...

to

   ... (fromString "foo") ...

we'd have instances like

instance StringLiteral String where fromString = id
instance StringLiteral PackedString where fromString = packString
...etc...

if not something in ghc, perhaps this might find its way into drift???

 - hal

--
Hal Daume III

 "Computer science is no more about computers    | [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to