Import hs-plugins cvs
This commit is contained in:
		
							
								
								
									
										4
									
								
								examples/reload/null/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								examples/reload/null/Makefile
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,4 @@
 | 
			
		||||
TEST=   reload/null
 | 
			
		||||
EXTRA_OBJS=Null.o
 | 
			
		||||
TOP=../../..
 | 
			
		||||
include ../../build.mk
 | 
			
		||||
							
								
								
									
										11
									
								
								examples/reload/null/Null.hs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								examples/reload/null/Null.hs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,11 @@
 | 
			
		||||
module Null ( resource, resource_dyn )  where
 | 
			
		||||
 | 
			
		||||
import API
 | 
			
		||||
import Data.Dynamic
 | 
			
		||||
import Prelude hiding (null)
 | 
			
		||||
 | 
			
		||||
resource = null
 | 
			
		||||
 | 
			
		||||
-- ! this has to be special: it can't be overridden by the user.
 | 
			
		||||
resource_dyn :: Dynamic
 | 
			
		||||
resource_dyn = toDyn resource
 | 
			
		||||
							
								
								
									
										12
									
								
								examples/reload/null/api/API.hs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								examples/reload/null/api/API.hs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
{-# OPTIONS -fglasgow-exts #-}
 | 
			
		||||
 | 
			
		||||
module API where
 | 
			
		||||
 | 
			
		||||
import Data.Dynamic
 | 
			
		||||
 | 
			
		||||
data Null = Null { a, b :: Int }
 | 
			
		||||
   deriving (Typeable, Show)
 | 
			
		||||
 | 
			
		||||
null :: Null
 | 
			
		||||
null = Null { a = 42 , b = 1 }
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										19
									
								
								examples/reload/null/prog/Main.hs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								examples/reload/null/prog/Main.hs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
			
		||||
 | 
			
		||||
import Plugins
 | 
			
		||||
import API
 | 
			
		||||
 | 
			
		||||
-- an example where we just want to load an object and run it
 | 
			
		||||
 | 
			
		||||
main = do 
 | 
			
		||||
    m_v <- load "../Null.o" ["../api"] [] "resource"
 | 
			
		||||
    (m,v) <- case m_v of
 | 
			
		||||
        LoadSuccess m v -> return (m,v)
 | 
			
		||||
        _               -> error "load failed"
 | 
			
		||||
    putStrLn ( show (a v) )
 | 
			
		||||
 | 
			
		||||
    m_v <- reload m "resource"   -- get a new version
 | 
			
		||||
    v' <- case m_v of
 | 
			
		||||
        LoadSuccess _ v -> return v
 | 
			
		||||
        _               -> error "load failed"
 | 
			
		||||
    putStrLn ( show (a v') )
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								examples/reload/null/prog/expected
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								examples/reload/null/prog/expected
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,2 @@
 | 
			
		||||
42
 | 
			
		||||
42
 | 
			
		||||
		Reference in New Issue
	
	Block a user