[Haskell-cafe] loading an Haskell symbol at run-time

2007-06-26 Thread Pasqualino 'Titto' Assini
Hi,

to load an Haskell symbol at run-time is still necessary to use the load 
functions from the hs-plugins library (System.Plugins.Load) or is there some 
function in the GHC API that does the same job?

Thanks,

titto
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] loading an Haskell symbol at run-time

2007-06-26 Thread Donald Bruce Stewart
tittoassini:
> Hi,
> 
> to load an Haskell symbol at run-time is still necessary to use the load 
> functions from the hs-plugins library (System.Plugins.Load) or is there some 
> function in the GHC API that does the same job?
> 

yes, definitely possible. i think Lemmih put an example on the wiki a
while ago. basically, ghc-api exposes the lower level api also used by
hs-plugins -- a nice project would be to provide the hs-plugins api
directly in ghc-api - avoiding the need for an external hs-plugins package.

-- Don
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] loading an Haskell symbol at run-time

2007-06-27 Thread Pasqualino 'Titto' Assini
On Wednesday 27 June 2007 03:06:15 Donald Bruce Stewart wrote:
> tittoassini:
> > Hi,
> >
> > to load an Haskell symbol at run-time is still necessary to use the load
> > functions from the hs-plugins library (System.Plugins.Load) or is there
> > some function in the GHC API that does the same job?
>
> yes, definitely possible. i think Lemmih put an example on the wiki a
> while ago. basically, ghc-api exposes the lower level api also used by
> hs-plugins -- a nice project would be to provide the hs-plugins api
> directly in ghc-api - avoiding the need for an external hs-plugins package.
>
> -- Don

Hi Don, thanks for the answer.

I checked again the http://haskell.org/haskellwiki/GHC/As_a_library page on 
the wiki and there are examples of interactive evaluation but I cannot find 
an example of loading a symbol from a compiled module.

If anyone can provide one, I will be happy to test it and add it to the "GHC 
as a library" Wiki page.

Regards,

 titto
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] loading an Haskell symbol at run-time

2007-06-27 Thread Donald Bruce Stewart
tittoassini:
> On Wednesday 27 June 2007 03:06:15 Donald Bruce Stewart wrote:
> > tittoassini:
> > > Hi,
> > >
> > > to load an Haskell symbol at run-time is still necessary to use the load
> > > functions from the hs-plugins library (System.Plugins.Load) or is there
> > > some function in the GHC API that does the same job?
> >
> > yes, definitely possible. i think Lemmih put an example on the wiki a
> > while ago. basically, ghc-api exposes the lower level api also used by
> > hs-plugins -- a nice project would be to provide the hs-plugins api
> > directly in ghc-api - avoiding the need for an external hs-plugins package.
> >
> > -- Don
> 
> Hi Don, thanks for the answer.
> 
> I checked again the http://haskell.org/haskellwiki/GHC/As_a_library page on 
> the wiki and there are examples of interactive evaluation but I cannot find 
> an example of loading a symbol from a compiled module.
> 

Yes, this is the part I meant about duplicating the hs-plugins API. Both
ghc-apii and hs-plugins use the following api from the runtime:

foreign import ccall unsafe "Linker.h lookupSymbol"
   pluginSym :: CString -> IO (Ptr a)

foreign import ccall unsafe "Linker.h loadObj"
   pluginLoad :: CString -> IO Bool

foreign import ccall unsafe "Linker.h initLinker"
   pluginInit :: IO ()

foreign import ccall unsafe "Linker.h resolveObjs"
   pluginResolve :: IO Bool

hs-plugins duplicates some of the ghci internals to find, resolve and load
packages and objects, and access their symbols. So that code must exist in the
ghci parts of the ghc-api. You'll have to peek around in there.

-- Don
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe