Update examples
This commit is contained in:
3
testsuite/make/simple/Makefile
Normal file
3
testsuite/make/simple/Makefile
Normal file
@ -0,0 +1,3 @@
|
||||
TEST= make/simple
|
||||
TOP=../../..
|
||||
include ../../build.mk
|
14
testsuite/make/simple/Tiny.hs
Normal file
14
testsuite/make/simple/Tiny.hs
Normal file
@ -0,0 +1,14 @@
|
||||
module Tiny ( resource, resource_dyn ) where
|
||||
|
||||
import API
|
||||
import Data.Dynamic
|
||||
|
||||
resource = tiny {
|
||||
|
||||
field = "hello strange world"
|
||||
|
||||
}
|
||||
|
||||
resource_dyn :: Dynamic
|
||||
resource_dyn = toDyn resource
|
||||
|
13
testsuite/make/simple/api/API.hs
Normal file
13
testsuite/make/simple/api/API.hs
Normal file
@ -0,0 +1,13 @@
|
||||
{-# OPTIONS -fglasgow-exts #-}
|
||||
-- ^ needed to derive Typeable
|
||||
|
||||
module API where
|
||||
|
||||
import Data.Dynamic
|
||||
|
||||
data Tiny = Tiny { field :: String }
|
||||
deriving (Typeable, Show)
|
||||
|
||||
tiny :: Tiny
|
||||
tiny = Tiny { field = "default value" }
|
||||
|
19
testsuite/make/simple/prog/Main.hs
Normal file
19
testsuite/make/simple/prog/Main.hs
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
-- little more complex. use the path to the obj file we get back from
|
||||
-- 'make'. load() uses this to find the .hi file
|
||||
|
||||
import System.Plugins
|
||||
import API
|
||||
|
||||
main = do
|
||||
status <- make "../Tiny.hs" ["-i../api"]
|
||||
o <- case status of
|
||||
MakeSuccess _ o -> return o
|
||||
MakeFailure e -> mapM_ putStrLn e >> error "failed"
|
||||
|
||||
m_v <- load o ["../api"] [] "resource"
|
||||
v <- case m_v of
|
||||
LoadSuccess _ v -> return v
|
||||
_ -> error "load failed"
|
||||
putStrLn $ field v
|
||||
|
1
testsuite/make/simple/prog/expected
Normal file
1
testsuite/make/simple/prog/expected
Normal file
@ -0,0 +1 @@
|
||||
hello strange world
|
Reference in New Issue
Block a user