
On Mon, Oct 27, 2008 at 07:00:00PM -0400, Brandon S. Allbery KF8NH wrote:
On 2008 Oct 27, at 17:33, Alex Shearn wrote:
Hey all - I've been trying to write an IRC bot following the guide on the wiki, and we (those of us on the channel) were trying to get it to evaluate commands. So far, we have this for "eval" stuff, but is there anyway to specify a "parse in haskell" sort of thing?
No, although you could fake it with the GHC-API (which basically means your bot has all of GHC built into it).
In any case, that's not really a good idea; consider what damage could be done by arbitrary code. A better idea is to link the code into a small program with a very restricted environment and run that with a timeout. See http://code.haskell.org/lambdabot/Plugin/Eval.hs.
Brandon is right that this is difficult and tricky -- but fortunately, someone else has already done the hard work for you! Take a look at the mueval package [1], which should allow you to do what you want. -Brent [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/mueval