how can I run ghci monad actions from ghci command line

Claus Reinke claus.reinke at
Mon Jan 26 13:31:47 EST 2009

>>> Is it possible to run ghci monad actions from ghci command line somehow?
>>> For example: I would like to check whether "it" variable is of type 
>>> Bool and whether it is True using normal Haskell code (i.e. not using 
>>> ghci commands starting with colon like :type :print).
> What I was searching for in this post was a possibility to write full 
> fledged plugins or something like that.
> Never mind, I already went through the initial pain of my custom change 
> to ghc so if I ever need something more complicated again I can do my 
> tests directly in the source code.

An intermediate approach between scripting GHCi and
modifying GHCi's source would be to use the GHC API.
You'd still need to read the source, but your code could be
used with any GHC (via the ghc package), not just with your
modified sources. I didn't mention this earlier because it doesn't
give you direct access to your GHCi session (you'd be running
a separate GHC session, for which you could provide GHCi
style frontend and debugger functionality, plus your plugins/
modifications), but if you're thinking plugins, the GHC API
is probably the way to go.

If the necessary functionality is not yet exposed through
the API, it probably should be (iirc, GHCi's frontend itself
isn't part of the API, but the functionality used by it is, so GHCi
is just one of several GHC API clients; don't know how far the 
debugger features you are interested in are tied to the frontend
or available for all GHC API sessions). As usual, there is the 
design question of what to expose and how, on which GHC HQ 
would like user input. Nothing is as helpful for that as an actual 
use case!-) So, yes, please do report on your experiments.


More information about the Glasgow-haskell-users mailing list