[Haskell] How to import user's modules with hs-plugins

Donald Bruce Stewart dons at cse.unsw.edu.au
Wed Mar 2 18:17:19 EST 2005


jgarciavivo:
> Hello everybody. I'm using the hs-plugins function "eval" in my source code and
> I need to import a Haskell module at runtime. Do you know if it's possible?
> I've seen many examples of hs-plugins and never had a user's module import in
> the "eval" call. Thanks for your time

If I understand you correctly, you are trying to control which modules
are in scope in the eval call?

Eval has type:
    eval :: Typeable a => String -> [Import] -> IO (Maybe a)

The 2nd argument is a list of module names to bring into scope during
the eval. So you can call it as:
    do ma <- eval "some string" ["Data.List"]

Cheers,
  Don


More information about the Haskell mailing list