There is the package hint, which embeds the calls to GHC API.
Quite easy to use:
Let's say your configuration file (cfg/Script.hs) contains a function
"script" that you want to get:
type ScriptFun = IO ()
loadScript :: IO ScriptFun
loadScript = do
liftM (either (error . show) id) $ runInterpreter $ do
path <- get searchPath
set [searchPath := ("./cfg":path)]
loadModules ["Script"]
setTopLevelModules ["Script"]
exports <- getModuleExports "Script"
if Fun "script" `elem` exports
then *interpret "script" (as :: ScriptFun)*
else error "script function not found"
There is just the line I put in bold that bothers me. Can't we get the
action "script" more easily than by re-interpreting some code?
2010/5/8 Brandon S. Allbery KF8NH <[email protected]>
> On May 4, 2010, at 01:52 , Maciej Piechotka wrote:
>
>> After change of file you have to wait a long time as it compiles and
>> links with yi. On my system (1 GB of RAM taken by system + 1 GB 'free' +
>> 2 GB swaps, x86-64) it could in some situations it caused OOM. I'd
>> prefer if the code was interpreted by ghci instead of compiled by GHC in
>> this case (it should be as fast as most of the code was compiled
>> anyway).
>>
>
>
> On the one hand, this is doable with the GHC API. On the other, that more
> or less means your program contains what amounts to a full copy of GHC.
>
> --
> brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [email protected]
> system administrator [openafs,heimdal,too many hats] [email protected]
> electrical and computer engineering, carnegie mellon university KF8NH
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe