7

I've been playing around with the plugins package. I want a host application to dynamically compile and load Haskell source files in a sandboxed environment. Compilation works just fine. Loading fails as soon as the plugin references modules available in the sandbox only. Here is what I've got for the plugin:

module Plugin (resource) where

import ServerAPI
import System.Plugins -- this module is only available in the sandbox

resource = Interface { action = timesTwo }

timesTwo :: Integer -> IO Integer
timesTwo n = return $ n * 2

Loading the plugin from the host application looks like this:

pkgConfDir = "/home/me/plugins/.cabal-sandbox/x86_64-osx-ghc-7.8.4-packages.conf.d
loadedOk <- pdynload "Plugin.o" ["."] [pkgConfDir] "ServerAPI.Interface" "resource"

This is what I've got in the sandbox:

> cabal sandbox hc-pkg list
…
/home/me/plugins/.cabal-sandbox/x86_64-osx-ghc-7.8.4-packages.conf.d
    plugins-1.5.4.0
…

This is what I get when running the host application:

Failed to load interface for ‘System.Plugins.Env’
no package matching ‘plugins-1.5.4.0’ was found

As mentioned above, when I get rid of the import System.Plugins statement in the plugin the code does load. What am I missing?

Edit:

The cabal file:

name:                plugins
version:             0.1.0.0
-- synopsis:
-- description:
-- license:
license-file:        LICENSE
author:              W. Davis
maintainer:          w.davis@spam.me.not
-- copyright:
-- category:
build-type:          Simple
-- extra-source-files:
cabal-version:       >=1.10

executable plugins
  main-is:             Main.hs
  -- other-modules:       
  -- other-extensions:
  build-depends:       base >=4.7 && <4.8, plugins >=1.5 && <1.6
  -- hs-source-dirs:
  default-language:    Haskell2010
W. Davis
  • 71
  • 3
  • Can you show your cabal file? – firefrorefiddle Mar 26 '15 at 05:42
  • I assumed the plugins package uses plain ghc. I've updated the question. – W. Davis Mar 26 '15 at 06:52
  • I'd assume the `plugins` package no longer works. It was last updated in 2013, and the GHC API has changed several times since then. – Cubic Jun 05 '15 at 17:28
  • @Cubic Looks like it was just updated for GHC 7.10 https://github.com/stepcut/plugins/commit/53a0f5b97bb305140a076d866eeabe4b1875f34b – levant pied Oct 22 '15 at 19:39
  • @levantpied Yep, but I know the guy who made those commits and I don't think he intends on maintaining it - I imagine he was just tinkering with plugins for a while. – Cubic Oct 22 '15 at 20:38

0 Answers0