"eval" in ghc(i)?

Geoffrey Alan Washburn geoffw at cis.upenn.edu
Wed May 3 15:20:52 EDT 2006


	I have an application written in OCaml that I'm interested in porting 
over to Haskell, and I was wondering what the best way to replace the 
following OCaml function would be:

Toploop.initialize_toplevel_env();;

let eval txt = let lb = (Lexing.from_string txt) in
  let phr = !Toploop.parse_toplevel_phrase lb in
  Toploop.execute_phrase true Format.std_formatter phr;;

eval "let add1 x = x +1;;";;
eval "add1 2;;";;

Where I would like to be able to "eval" Haskell-code instead.  It looks 
like I might be able to achieve something like this using hs-plugins, 
but it looks a bit more complex.  Is hs-plugins the best choice for this 
kind of "meta"-programming?  I'm pretty sure Template Haskell will not 
work for me, at least as I understand it I can only manipulate program 
fragments that will be compiled later and as such that it will not be 
possible to execute them until the next "phase".



More information about the Glasgow-haskell-users mailing list