Update examples
This commit is contained in:
5
testsuite/pdynload/spj4/Makefile
Normal file
5
testsuite/pdynload/spj4/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
TEST=pdynload/spj4
|
||||
|
||||
TOP=../../..
|
||||
include ../../build.mk
|
16
testsuite/pdynload/spj4/Plugin.hs
Normal file
16
testsuite/pdynload/spj4/Plugin.hs
Normal file
@ -0,0 +1,16 @@
|
||||
module Plugin where
|
||||
|
||||
-- user doesn't import the API
|
||||
-- and provides a polymorphic value
|
||||
|
||||
-- import API
|
||||
-- resource :: Interface
|
||||
|
||||
--
|
||||
-- should pass type check, and dump core
|
||||
--
|
||||
-- resource :: Num a => a
|
||||
|
||||
import API
|
||||
|
||||
resource = Interface { field = 7 :: Num a => a }
|
5
testsuite/pdynload/spj4/api/API.hs
Normal file
5
testsuite/pdynload/spj4/api/API.hs
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
module API where
|
||||
|
||||
newtype Interface = Interface { field :: Int }
|
||||
|
17
testsuite/pdynload/spj4/prog/Main.hs
Normal file
17
testsuite/pdynload/spj4/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 -> error "there was a type error"
|
||||
|
||||
where f = do v <- pdynload "../Plugin.o" ["../api"] [] "API.Interface" "resource"
|
||||
case v of
|
||||
LoadSuccess _ (a :: Interface) -> print $ field a -- will crash
|
||||
LoadFailure es -> mapM_ putStrLn es
|
1
testsuite/pdynload/spj4/prog/expected
Normal file
1
testsuite/pdynload/spj4/prog/expected
Normal file
@ -0,0 +1 @@
|
||||
7
|
Reference in New Issue
Block a user