[racket] Strings as lists

From: Timothy Farland (twfarland at googlemail.com)
Date: Sat Mar 3 04:13:25 EST 2012

Hi racket folk, lisp neophyte here (just finished HTDP),

I would like to use Haskell-style strings in my racket, where a string is
defined as either '() or (cons character string), and is read from and
displayed by values enclosed by double quotes.

i.e: "string" is understood as '(#\s #\t #\r #\i #\n #\g) and '(#\s #\t #\r
#\i #\n #\g) is displayed as "string".

.. so one could do, for example (car "string") => #\s, or (cdr "string") =>
"tring" etc.

I've made altered versions of the basic list processing functions that act
differently when given strings or lists, so they achieve this, but at the
cost of a lot of runtime checks.

For a better approach I suspect one would need to deal with the 'reader,'
but looking at the documentation, it seems a bit beyond my current

Has anyone else seen or built a language extension that achieves this, or
could anyone point me to some next-step resources that will bring me up to
the level where I can understand the reader documentation? Or is my
enterprise here misguided?

Many thanks

Tim Farland
e:twfarland at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120303/11558d4b/attachment.html>

Posted on the users mailing list.