Update examples
This commit is contained in:
5
testsuite/makewith/tiny/Makefile
Normal file
5
testsuite/makewith/tiny/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
TEST=makewith/tiny
|
||||
|
||||
TOP=../../..
|
||||
include ../../build.mk
|
8
testsuite/makewith/tiny/Tiny.conf
Normal file
8
testsuite/makewith/tiny/Tiny.conf
Normal file
@ -0,0 +1,8 @@
|
||||
resource = tiny {
|
||||
|
||||
field = "hello strange world"
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
31
testsuite/makewith/tiny/Tiny.stub
Normal file
31
testsuite/makewith/tiny/Tiny.stub
Normal file
@ -0,0 +1,31 @@
|
||||
module Tiny ( resource, resource_dyn ) where
|
||||
|
||||
import API
|
||||
import Data.Dynamic
|
||||
|
||||
resource = tiny
|
||||
|
||||
resource_dyn :: Dynamic
|
||||
resource_dyn = toDyn resource
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
13
testsuite/makewith/tiny/api/API.hs
Normal file
13
testsuite/makewith/tiny/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" }
|
||||
|
21
testsuite/makewith/tiny/prog/Main.hs
Normal file
21
testsuite/makewith/tiny/prog/Main.hs
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
import System.Plugins
|
||||
import API
|
||||
import Data.Either
|
||||
|
||||
conf = "../Tiny.conf"
|
||||
stub = "../Tiny.stub"
|
||||
apipath = "../api"
|
||||
|
||||
main = do
|
||||
status <- makeWith conf stub ["-i"++apipath]
|
||||
o <- case status of
|
||||
MakeFailure e -> mapM_ putStrLn e >> error "failed"
|
||||
MakeSuccess _ o -> return o
|
||||
m_v <- load o [apipath] [] "resource"
|
||||
v <- case m_v of
|
||||
LoadSuccess _ v -> return v
|
||||
_ -> error "load failed"
|
||||
putStrLn $ field v
|
||||
makeCleaner o
|
||||
|
1
testsuite/makewith/tiny/prog/expected
Normal file
1
testsuite/makewith/tiny/prog/expected
Normal file
@ -0,0 +1 @@
|
||||
hello strange world
|
Reference in New Issue
Block a user