Import hs-plugins cvs

This commit is contained in:
Don Stewart
2005-04-24 08:51:33 +00:00
commit 887fa59389
494 changed files with 23721 additions and 0 deletions

View File

@ -0,0 +1,6 @@
TEST= multi/3plugins
EXTRA_OBJS=Plugin1.o Plugin2.o Plugin3.o
TOP=../../..
include ../../build.mk

View File

@ -0,0 +1,8 @@
module Plugin1 where
import API
import Data.Char
resource = plugin {
valueOf = map toUpper
}

View File

@ -0,0 +1,9 @@
module Plugin2 where
import API
import Data.Char
resource = plugin {
valueOf = \s -> show $ map ord s
}

View File

@ -0,0 +1,7 @@
module Plugin3 where
import API
resource = plugin {
valueOf = reverse
}

View File

@ -0,0 +1,9 @@
module API where
data Interface = Interface {
valueOf :: String -> String
}
plugin :: Interface
plugin = Interface { valueOf = id }

View File

@ -0,0 +1,13 @@
import Plugins
import API
main = do
let plist = ["../Plugin1.o", "../Plugin2.o", "../Plugin3.o"]
plugins <- mapM (\p -> load p ["../api"] [] "resource") plist
let functions = map (valueOf . fromLoadSuc) plugins
-- apply the function from each plugin in turn
mapM_ (\f -> putStrLn $ f "haskell is for hackers") functions
fromLoadSuc (LoadFailure _) = error "load failed"
fromLoadSuc (LoadSuccess _ v) = v

View File

@ -0,0 +1,3 @@
HASKELL IS FOR HACKERS
[104,97,115,107,101,108,108,32,105,115,32,102,111,114,32,104,97,99,107,101,114,115]
srekcah rof si lleksah