Update examples
This commit is contained in:
6
testsuite/multi/3plugins/Makefile
Normal file
6
testsuite/multi/3plugins/Makefile
Normal file
@ -0,0 +1,6 @@
|
||||
TEST= multi/3plugins
|
||||
|
||||
EXTRA_OBJS=Plugin1.o Plugin2.o Plugin3.o
|
||||
|
||||
TOP=../../..
|
||||
include ../../build.mk
|
8
testsuite/multi/3plugins/Plugin1.hs
Normal file
8
testsuite/multi/3plugins/Plugin1.hs
Normal file
@ -0,0 +1,8 @@
|
||||
module Plugin1 where
|
||||
|
||||
import API
|
||||
import Data.Char
|
||||
|
||||
resource = plugin {
|
||||
valueOf = map toUpper
|
||||
}
|
9
testsuite/multi/3plugins/Plugin2.hs
Normal file
9
testsuite/multi/3plugins/Plugin2.hs
Normal file
@ -0,0 +1,9 @@
|
||||
module Plugin2 where
|
||||
|
||||
import API
|
||||
import Data.Char
|
||||
|
||||
resource = plugin {
|
||||
valueOf = \s -> show $ map ord s
|
||||
}
|
||||
|
7
testsuite/multi/3plugins/Plugin3.hs
Normal file
7
testsuite/multi/3plugins/Plugin3.hs
Normal file
@ -0,0 +1,7 @@
|
||||
module Plugin3 where
|
||||
|
||||
import API
|
||||
|
||||
resource = plugin {
|
||||
valueOf = reverse
|
||||
}
|
9
testsuite/multi/3plugins/api/API.hs
Normal file
9
testsuite/multi/3plugins/api/API.hs
Normal file
@ -0,0 +1,9 @@
|
||||
module API where
|
||||
|
||||
data Interface = Interface {
|
||||
valueOf :: String -> String
|
||||
}
|
||||
|
||||
plugin :: Interface
|
||||
plugin = Interface { valueOf = id }
|
||||
|
13
testsuite/multi/3plugins/prog/Main.hs
Normal file
13
testsuite/multi/3plugins/prog/Main.hs
Normal file
@ -0,0 +1,13 @@
|
||||
import System.Plugins
|
||||
import API
|
||||
|
||||
main = do
|
||||
let plist = ["../Plugin1.o", "../Plugin2.o", "../Plugin3.o"]
|
||||
plugins <- mapM (\p -> load p ["../api"] [] "resource") plist
|
||||
let functions = map (valueOf . fromLoadSuc) plugins
|
||||
|
||||
-- apply the function from each plugin in turn
|
||||
mapM_ (\f -> putStrLn $ f "haskell is for hackers") functions
|
||||
|
||||
fromLoadSuc (LoadFailure _) = error "load failed"
|
||||
fromLoadSuc (LoadSuccess _ v) = v
|
3
testsuite/multi/3plugins/prog/expected
Normal file
3
testsuite/multi/3plugins/prog/expected
Normal file
@ -0,0 +1,3 @@
|
||||
HASKELL IS FOR HACKERS
|
||||
[104,97,115,107,101,108,108,32,105,115,32,102,111,114,32,104,97,99,107,101,114,115]
|
||||
srekcah rof si lleksah
|
Reference in New Issue
Block a user