Update examples

This commit is contained in:
Don Stewart
2005-09-03 04:45:14 +00:00
parent 5321754614
commit dff0363224
421 changed files with 19 additions and 9 deletions

View File

@ -0,0 +1,8 @@
TEST= hier/hier1
EXTRA_OBJS=Plugin.o
PRIOR_OBJS=Modules/Flags.o
EXTRAFLAGS=
TOP=../../..
include ../../build.mk

View File

@ -0,0 +1,15 @@
--
-- A simple module
--
module Modules.Flags where
data FlagRec = FlagRec {
f1 :: Int,
f2 :: Int
}
foo :: FlagRec -> Int
foo x = f1 x

View File

@ -0,0 +1,6 @@
all:
ghc -O -c Flags.hs
clean:
rm -f *.hi *.o

View File

@ -0,0 +1,14 @@
--
-- Plugin
--
module Plugin where
import API
import Modules.Flags as Flags
resource = plugin {
dbFunc = (\x -> Flags.f1 x)
}

View File

@ -0,0 +1,16 @@
--
-- API for plugin test
--
module API where
import Modules.Flags as Flags
data Interface = Interface {
dbFunc :: Flags.FlagRec -> Int
}
plugin :: Interface
plugin = Interface { dbFunc = (\x -> 1) }

View File

@ -0,0 +1,21 @@
--
-- Test multiple plugins
--
module Main where
import System.Plugins
import API
import Modules.Flags as Flags
rec = Flags.FlagRec { Flags.f1 = 4, Flags.f2 = 10 }
main = do
status <- load "../Plugin.o" ["../api",".."] [] "resource"
case status of
LoadFailure _ -> error "load failed"
LoadSuccess _ v -> do let func = dbFunc v
print (func rec)

View File

@ -0,0 +1 @@
4