Import hs-plugins cvs
This commit is contained in:
6
examples/load/thiemann2/C.hs
Normal file
6
examples/load/thiemann2/C.hs
Normal file
@ -0,0 +1,6 @@
|
||||
module C where
|
||||
|
||||
import API
|
||||
import qualified A
|
||||
|
||||
resource = let Test s = A.resource in Test { field = s }
|
6
examples/load/thiemann2/Makefile
Normal file
6
examples/load/thiemann2/Makefile
Normal file
@ -0,0 +1,6 @@
|
||||
TEST= load/thiemann2
|
||||
EXTRAFLAGS+=-iprog
|
||||
|
||||
TOP=../../..
|
||||
include ../../build.mk
|
||||
|
8
examples/load/thiemann2/api/API.hs
Normal file
8
examples/load/thiemann2/api/API.hs
Normal file
@ -0,0 +1,8 @@
|
||||
module API where
|
||||
|
||||
data Test = Test {
|
||||
field :: String
|
||||
}
|
||||
|
||||
test :: Test
|
||||
test = Test { field = "default value" }
|
8
examples/load/thiemann2/prog/A.hs
Normal file
8
examples/load/thiemann2/prog/A.hs
Normal file
@ -0,0 +1,8 @@
|
||||
module A where
|
||||
|
||||
import API
|
||||
|
||||
import qualified B
|
||||
|
||||
resource = Test { field = B.resource }
|
||||
|
3
examples/load/thiemann2/prog/B.hs
Normal file
3
examples/load/thiemann2/prog/B.hs
Normal file
@ -0,0 +1,3 @@
|
||||
module B where
|
||||
|
||||
resource = "i'm in b"
|
20
examples/load/thiemann2/prog/Main.hs
Normal file
20
examples/load/thiemann2/prog/Main.hs
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
import Plugins
|
||||
import API
|
||||
|
||||
import A
|
||||
|
||||
main = do
|
||||
-- compile C (A and B are already compiled)
|
||||
status <- makeAll "../C.hs" ["-i../api"]
|
||||
obj <- case status of
|
||||
MakeSuccess _ o -> return o
|
||||
MakeFailure e -> mapM_ putStrLn e >> error "failed"
|
||||
|
||||
-- should load C
|
||||
m_v <- load_ obj ["../api","."] "resource"
|
||||
v <- case m_v of
|
||||
LoadFailure _ -> error "load failed"
|
||||
LoadSuccess _ v -> return v
|
||||
let s = field v
|
||||
print s
|
1
examples/load/thiemann2/prog/expected
Normal file
1
examples/load/thiemann2/prog/expected
Normal file
@ -0,0 +1 @@
|
||||
"i'm in b"
|
Reference in New Issue
Block a user