Eval in Haskell

Matt Hellige matt@immute.net
Mon, 2 Jun 2003 09:16:41 -0500


[oleg@pobox.com]
> 
> Furthermore, if GHCi can (after some prodding by the user) launch ghc
> to compile a module and then load the resulting .o file in and
> apply some function in thus loaded file, doesn't it feel like an eval?
> 

Yes, I think both of your solutions are workable in principle and in
certain practical settings, but they are both pretty heavy. In a
language that encouraged the use of eval, I would hope it would be a
considerably less expensive operation. My feeling is that as long as
it's non-standard and heavy, eval will not become idiomatic in
Haskell, and programmers who desire/require a lightweight eval will
continue to look elsewhere. Further, these workarounds offer only the
most rudimentary ability to handle errors or other exceptional
conditions.

Incidentally, it would be my enormous preference for eval to work on a
structured representation of an expression rather than a string. This
is one area where the weakness of Python-style eval is really exposed,
when compared to Lisp. I'd suggest re-using the new stuff that has
been introduced for template-Haskell here, and keeping parsing
separate.

Matt

-- 
Matt Hellige                  matt@immute.net
http://matt.immute.net