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,4 @@
TEST= dynload/should_fail
EXTRA_OBJS=Plugin.o
TOP=../../..
include ../../build.mk

View File

@ -0,0 +1,12 @@
{-# OPTIONS -fglasgow-exts #-}
module Plugin where
import API
import AltData.Dynamic
v :: Int
v = 0xdeadbeef
resource_dyn :: Dynamic
resource_dyn = toDyn v

View File

@ -0,0 +1,20 @@
{-# OPTIONS -fglasgow-exts #-}
module API where
import AltData.Typeable
data Interface = Interface {
function :: String
}
instance Typeable Interface where
#if __GLASGOW_HASKELL__ >= 603
typeOf i = mkTyConApp (mkTyCon "API.Interface") []
#else
typeOf i = mkAppTy (mkTyCon "API.Interface") []
#endif
plugin :: Interface
plugin = Interface { function = "goodbye" }

View File

@ -0,0 +1,14 @@
import System.Plugins
import API
main = do
m_v <- dynload "../Plugin.o"
["../api"]
[]
"resource_dyn"
case m_v of
LoadFailure _ -> putStrLn "didn't compile"
LoadSuccess _ v -> putStrLn $ function v

View File

@ -0,0 +1,4 @@
Couldn't match `API.Interface' against `Int'
Expected type: API.Interface
Inferred type: Int
didn't compile