Update examples
This commit is contained in:
5
testsuite/pdynload/poly/Makefile
Normal file
5
testsuite/pdynload/poly/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
TEST=pdynload/poly
|
||||
|
||||
TOP=../../..
|
||||
include ../../build.mk
|
9
testsuite/pdynload/poly/Plugin.hs
Normal file
9
testsuite/pdynload/poly/Plugin.hs
Normal file
@ -0,0 +1,9 @@
|
||||
module Plugin where
|
||||
|
||||
import Data.Generics.Schemes
|
||||
|
||||
import API
|
||||
|
||||
resource = rsrc {
|
||||
field = id listify
|
||||
}
|
12
testsuite/pdynload/poly/api/API.hs
Normal file
12
testsuite/pdynload/poly/api/API.hs
Normal file
@ -0,0 +1,12 @@
|
||||
{-# OPTIONS -fglasgow-exts #-}
|
||||
-- a really nasty type:
|
||||
|
||||
module API where
|
||||
|
||||
import Data.Generics
|
||||
|
||||
data Interface = Interface { field :: Typeable r => (r -> Bool) -> GenericQ [r] }
|
||||
|
||||
rsrc :: Interface
|
||||
rsrc = Interface { field = listify }
|
||||
|
17
testsuite/pdynload/poly/prog/Main.hs
Normal file
17
testsuite/pdynload/poly/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/poly/prog/expected
Normal file
1
testsuite/pdynload/poly/prog/expected
Normal file
@ -0,0 +1 @@
|
||||
loaded .. yay!
|
Reference in New Issue
Block a user