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,69 @@
--
-- Copyright (c) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons
-- GPL version 2 or later (see http://www.gnu.org/copyleft/gpl.html)
--
import Eval.Haskell
import Plugins.Load
import System.Exit ( ExitCode(..), exitWith )
import System.IO
import System.Console.Readline ( readline, addHistory )
symbol = "resource"
main = do
putStrLn banner
putStr "Loading package base" >> hFlush stdout
loadPackage "base"
putStr " ... linking ... " >> hFlush stdout
resolveObjs
putStrLn "done"
shell []
shell :: [String] -> IO ()
shell imps = do
s <- readline "plugs> "
cmd <- case s of
Nothing -> exitWith ExitSuccess
Just (':':'q':_) -> exitWith ExitSuccess
Just s -> addHistory s >> return s
imps' <- run cmd imps
shell imps'
run :: String -> [String] -> IO [String]
run "" is = return is
run ":?" is = putStrLn help >> return is
run ":l" _ = return []
run (':':'l':' ':m) is = return (m:is)
run (':':'t':' ':s) is = do
ty <- typeOf s is
when (not $ null ty) (putStrLn $ s ++ " :: " ++ ty)
return is
run (':':_) is = putStrLn help >> return is
run s is = do
s <- unsafeEval ("show $ "++s) is
when (isJust s) (putStrLn (fromJust s))
return is
banner = "\
\ __ \n\
\ ____ / /_ ______ ______ \n\
\ / __ \\/ / / / / __ `/ ___/ PLugin User's GHCi System, for Haskell 98\n\
\ / /_/ / / /_/ / /_/ (__ ) http://www.cse.unsw.edu.au/~dons/hs-plugins\n\
\ / .___/_/\\__,_/\\__, /____/ Type :? for help \n\
\/_/ /____/ \n"
help = "\
\Commands :\n\
\ <expr> evaluate expression\n\
\ :t <expr> show type of expression (monomorphic only)\n\
\ :l module bring module in to scope\n\
\ :l clear module list\n\
\ :quit quit\n\
\ :? display this list of commands"

View File

@ -0,0 +1,29 @@
GHCFLAGS= -O
PKGFLAGS= -package-conf $(TOP)/plugins.conf.inplace
PKGFLAGS+= -package eval -package readline
all: build
build:
@$(GHC) $(GHCFLAGS) $(PKGFLAGS) $(EXTRAFLAGS) Main.hs -o plugs
check: build
@(if [ -f "expected" ] ;\
then \
actual_out="/tmp/hs-plugins-actual.out.$$$$" ;\
diff_out="/tmp/hs-plugins.diff.$$$$" ;\
cat test.in | ./plugs > $$actual_out 2>&1 || true ;\
diff -u expected $$actual_out > $$diff_out || true ;\
if [ -s "$$diff_out" ] ; then \
echo "failed with:" ;\
cat "$$diff_out" | sed '1,3d' ;\
else \
echo "ok." ;\
fi ;\
rm $$actual_out ;\
else \
cat test.in | ./plugs 2>&1 || true ;\
fi)
clean:
rm -rf *.hi *.o *~ *.dep ./plugs
include ../../../config.mk

View File

@ -0,0 +1,9 @@
__
____ / /_ ______ ______
/ __ \/ / / / / __ `/ ___/ PLugin User's GHCi System, for Haskell 98
/ /_/ / / /_/ / /_/ (__ ) http://www.cse.unsw.edu.au/~dons/hs-plugins
/ .___/_/\__,_/\__, /____/ Type :? for help
/_/ /____/
Loading package base ... linking ... plugs> plugs> done
453973694165307953197296969697410619233826

View File

@ -0,0 +1,2 @@
let fibs = 1 : 1 : zipWith (+) fibs (tail fibs) in fibs !! 200
:quit