Update examples
This commit is contained in:
4
testsuite/pdynload/univquant/Makefile
Normal file
4
testsuite/pdynload/univquant/Makefile
Normal file
@ -0,0 +1,4 @@
|
||||
TEST= pdynload/univquant
|
||||
EXTRA_OBJS=Plugin.o
|
||||
TOP=../../..
|
||||
include ../../build.mk
|
8
testsuite/pdynload/univquant/Plugin.hs
Normal file
8
testsuite/pdynload/univquant/Plugin.hs
Normal file
@ -0,0 +1,8 @@
|
||||
module Plugin where
|
||||
|
||||
import API
|
||||
|
||||
resource = plugin { function = my_id }
|
||||
|
||||
my_id :: forall a. a -> a
|
||||
my_id x = x
|
9
testsuite/pdynload/univquant/api/API.hs
Normal file
9
testsuite/pdynload/univquant/api/API.hs
Normal file
@ -0,0 +1,9 @@
|
||||
module API where
|
||||
|
||||
data Interface = Interface {
|
||||
function :: forall a. a -> a
|
||||
}
|
||||
|
||||
plugin :: Interface
|
||||
plugin = Interface { function = id }
|
||||
|
17
testsuite/pdynload/univquant/prog/Main.hs
Normal file
17
testsuite/pdynload/univquant/prog/Main.hs
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
import System.Plugins
|
||||
import API
|
||||
|
||||
src = "../Plugin.hs"
|
||||
wrap = "../Wrapper.hs"
|
||||
apipath = "../api"
|
||||
|
||||
main = do status <- make src ["-i"++apipath]
|
||||
case status of
|
||||
MakeSuccess _ _ -> f
|
||||
MakeFailure e -> mapM_ putStrLn e
|
||||
|
||||
where f = do v <- pdynload "../Plugin.o" ["../api"] [] "API.Interface" "resource"
|
||||
case v of
|
||||
LoadSuccess _ a -> putStrLn "loaded .. yay!"
|
||||
_ -> putStrLn "wrong types"
|
1
testsuite/pdynload/univquant/prog/expected
Normal file
1
testsuite/pdynload/univquant/prog/expected
Normal file
@ -0,0 +1 @@
|
||||
loaded .. yay!
|
Reference in New Issue
Block a user