[MLton] Hoisting the MLton tracer out of MLton?
Vesa Karvonen
vesa.a.j.k at gmail.com
Wed Mar 5 10:00:03 PST 2008
On Tue, Mar 4, 2008 at 6:50 PM, Jesper Louis Andersen
<jesper.louis.andersen at gmail.com> wrote:
> I am working on a project where I have a CPS-transform of some code. To get
> a view on what is going on, I thought about using the MLton modules:
>
> signature LAYOUT
> structure Layout
> signature TRACE*
> structure Trace
>
> for doing this. However, one needs to rewrite them a bit in order to be able
> to use the code outside MLton. So: Has anyone done this -- and if not: Would
> somebody be interested in having it as code in the mltonlib?
>
> Suggestions on hoisting it out is welcome as well!
If you want to use those modules and you need to hoist them out to do
that, then I'd say go for it, add them to mltonlib.
BTW, mltonlib currently has at least one library for pretty printing
(LAYOUT is a pretty printing library):
http://mlton.org/cgi-bin/viewsvn.cgi/*checkout*/mltonlib/trunk/com/ssh/prettier/unstable/public/prettier.sig
There is also a generic pretty printing function for printing SML data
in SML syntax:
http://mlton.org/cgi-bin/viewsvn.cgi/*checkout*/mltonlib/trunk/com/ssh/generic/unstable/public/value/pretty.sig
Using the generic pretty printing function, implementing a trace
facility should be a walk in the park. The memoize example has the
"loud" function, which is a truly simplistic trace facility:
http://mlton.org/cgi-bin/viewsvn.cgi/*checkout*/mltonlib/trunk/com/ssh/generic/unstable/example/memoize.sml
Also, you might perhaps like to try using the generics library for
processing your language. In particular, the Uniplate generic
http://mlton.org/cgi-bin/viewsvn.cgi/*checkout*/mltonlib/trunk/com/ssh/generic/unstable/public/value/uniplate.sig
is likely to be useful. As mentioned in the signature, it is inspired
by a Haskell library by the same name that has been used for language
processing. I've implemented (but not yet committed) a second version
of the canonize example
http://mlton.org/cgi-bin/viewsvn.cgi/*checkout*/mltonlib/trunk/com/ssh/generic/unstable/example/canonize.sml
from the generic library using the Uniplate generic (and
revised/extended it in the process, but not yet committed) and it
seems to lead to considerably simpler code.
If you need help with the libraries, I'd be happy to help. I'm also
available for chatting via gmail.
Note: By mentioning these libraries, I don't mean to suggest that you
should not add Layout and Trace to mltonlib. Having alternatives is a
good thing and there currently is no comprehensive trace facility in
mltonlib (AFAIK).
-Vesa Karvonen
More information about the MLton
mailing list