The beginnings of a GHCi test suite.
--- /dev/null
+#-----------------------------------------------------------------------------
+# $Id: Makefile,v 1.1 2001/03/01 15:36:20 simonmar Exp $
+
+TOP = ..
+include $(TOP)/mk/boilerplate.mk
+
+SUBDIRS=$(wildcard prog*/)
+
+include $(TOP)/mk/ghci.mk
--- /dev/null
+-- bug: shouldn't be defaulting these expressions
+:type (+)
+:type enumFromTo
--- /dev/null
+-- bug: we used to throw away the instance accidentally here
+:m PrelBase
+1 == (2 :: Int)
+1 == (2 :: Int)
--- /dev/null
+ ___ ___ _
+ / _ \ /\ /\/ __(_)
+ / /_\// /_/ / / | | GHC Interactive, version 4.11, For Haskell 98.
+/ /_\\/ __ / /___| | http://www.haskell.org/ghc/
+\____/\/ /_/\____/|_| Type :? for help.
+
+Loading package std ... linking ... done.
+Prelude> -- bug: we used to throw away the instance accidentally here
+Prelude> :m PrelBase
+PrelBase> 1 == (2 :: Int)
+False
+PrelBase> 1 == (2 :: Int)
+False
+PrelBase> Leaving GHCi.
--- /dev/null
+module Main where
+
+import B
+
+main = print ("hello world" ++ show (f 42))
--- /dev/null
+module B (module B, module C) where
+
+import C
+
+k x = x `mod` 11
--- /dev/null
+module C (f, g, h) where
+
+import D
+
+g x = f x + 1
+
+h x = x `div` 2
--- /dev/null
+module D where
+
+data T = A Int | B Float deriving Eq
+
+f x = x + 1
--- /dev/null
+module D where
+
+data T = A Int | B Float deriving Eq
+
+f x = x + x
--- /dev/null
+module D where
+
+data T = A Int | B Float deriving Eq
+
+f x = x + 1
--- /dev/null
+#-----------------------------------------------------------------------------
+# $Id: Makefile,v 1.1 2001/03/01 15:36:20 simonmar Exp $
+
+TOP = ../..
+include $(TOP)/mk/boilerplate.mk
+
+include $(TOP)/mk/ghci.mk
--- /dev/null
+-- first, tidy up:
+:unset +s
+:! rm -f *.hi *.o *~
+:! cp D1.hs D.hs
+
+-- load the program (all interpreted)
+:load A
+
+-- reloading should do nothing
+:reload
+
+-- make sure `main' works
+main
+
+-- touch a module + recompile
+:! touch C.hs
+:reload
+
+-- make sure `main' still works
+main
+
+-- compile D & reload
+:! $HC $HC_OPTS -no-recomp -c D.hs
+:reload
+main
+
+-- change A, recompile & reload
+:! cp D2.hs D.hs
+:! $HC $HC_OPTS -no-recomp -c D.hs
+:reload
+:load A
+
+-- make sure we're picking up the new D, via B
+:module B
+g 42
--- /dev/null
+Compiling D (D.hs)
+Compiling C (C.hs)
+Compiling B (B.hs)
+Compiling Main (A.hs)
+Compiling D (D.hs)
+Skipping C (C.hs)
+Skipping B (B.hs)
+Skipping Main (A.hs)
+Skipping D (D.hs)
+ (using D.o)
+Compiling C (C.hs)
+Compiling B (B.hs)
+Compiling Main (A.hs)
--- /dev/null
+ ___ ___ _
+ / _ \ /\ /\/ __(_)
+ / /_\// /_/ / / | | GHC Interactive, version 4.11, For Haskell 98.
+/ /_\\/ __ / /___| | http://www.haskell.org/ghc/
+\____/\/ /_/\____/|_| Type :? for help.
+
+Loading package std ... linking ... done.
+Prelude> -- first, tidy up:
+Prelude> :unset +s
+Prelude> :! rm -f *.hi *.o *~
+Prelude> :! cp D1.hs D.hs
+Prelude>
+Prelude> -- load the program (all interpreted)
+Prelude> :load A
+Ok, modules loaded: Main, B, C, D.
+Main>
+Main> -- reloading should do nothing
+Main> :reload
+Ok, modules loaded: Main, B, C, D.
+Main>
+Main> -- make sure `main' works
+Main> main
+"hello world84"
+Main>
+Main> -- touch a module + recompile
+Main> :! touch C.hs
+Main> :reload
+Ok, modules loaded: Main, B, C, D.
+Main>
+Main> -- make sure `main' still works
+Main> main
+"hello world84"
+Main>
+Main> -- compile D & reload
+Main> :! $HC $HC_OPTS -no-recomp -c D.hs
+Main> :reload
+Ok, modules loaded: Main, B, C, D.
+Main> main
+"hello world84"
+Main>
+Main> -- change A, recompile & reload
+Main> :! cp D2.hs D.hs
+Main> :! $HC $HC_OPTS -no-recomp -c D.hs
+Main> :reload
+Ok, modules loaded: Main, B, C, D.
+Main> :load A
+Ok, modules loaded: Main, B, C, D.
+Main>
+Main> -- make sure we're picking up the new D, via B
+Main> :module B
+B> g 42
+44
+B> Leaving GHCi.
--- /dev/null
+module A where
+
+data T = A Int | B Float deriving Eq
+
+f :: Int -> Int
+f x = x + 3
--- /dev/null
+module A where
+
+data T = A Int | B Float deriving Eq
+
+f :: Double -> Double
+f x = x + x
--- /dev/null
+module A where
+
+data T = A Int | B Float deriving Eq
+
+f :: Int -> Int
+f x = x + 3
--- /dev/null
+module B (f, g, h) where
+
+import A
+
+g x = f x + 1
+
+h x = x `div` 2
--- /dev/null
+module C (module B, module C) where
+
+import B
+
+k x = x `mod` 11
--- /dev/null
+module Main where
+
+import C
+
+main = print ("hello world" ++ show (f 42))
--- /dev/null
+#-----------------------------------------------------------------------------
+# $Id: Makefile,v 1.1 2001/03/01 15:36:20 simonmar Exp $
+
+TOP = ../..
+include $(TOP)/mk/boilerplate.mk
+
+include $(TOP)/mk/ghci.mk
--- /dev/null
+-- first, clean up:
+:! rm -f *.hi *.o *~
+:unset +s
+:! cp A1.hs A.hs
+
+:load D
+
+-- compile A & reload
+:! $HC $HC_OPTS -no-recomp -c A.hs
+:reload
+
+B.g 42
+B.g 42
+B.g 42
+
+-- swap A2 for A, compile & reload
+:! cp A2.hs A.hs
+:! $HC $HC_OPTS -no-recomp -c A.hs
+:reload
+-- the system should ignore the compiled version and compile its own.
+
+B.g 42
+B.g 42
+B.g 42
+
+-- pick up newly compiled A
+:load D
+
+B.g 42
+B.g 42
+B.g 42
+
+-- remove A.o: system should recompile A
+:! rm A.o
+:reload
+
+B.g 42
+B.g 42
+B.g 42
--- /dev/null
+Compiling A (A.hs)
+Compiling B (B.hs)
+Compiling C (C.hs)
+Compiling Main (D.hs)
+Compiling A (A.hs)
+Compiling B (B.hs)
+Skipping C (C.hs)
+Compiling Main (D.hs)
+Skipping A (A.hs)
+ (using A.o)
+Compiling B (B.hs)
+Compiling C (C.hs)
+Compiling Main (D.hs)
+Compiling A (A.hs)
+Skipping B (B.hs)
+Skipping C (C.hs)
+Skipping Main (D.hs)
--- /dev/null
+ ___ ___ _
+ / _ \ /\ /\/ __(_)
+ / /_\// /_/ / / | | GHC Interactive, version 4.11, For Haskell 98.
+/ /_\\/ __ / /___| | http://www.haskell.org/ghc/
+\____/\/ /_/\____/|_| Type :? for help.
+
+Loading package std ... linking ... done.
+Prelude> -- first, clean up:
+Prelude> :! rm -f *.hi *.o *~
+Prelude> :unset +s
+Prelude> :! cp A1.hs A.hs
+Prelude>
+Prelude> :load D
+Ok, modules loaded: Main, C, B, A.
+Main>
+Main> -- compile A & reload
+Main> :! $HC $HC_OPTS -no-recomp -c A.hs
+Main> :reload
+Ok, modules loaded: Main, C, B, A.
+Main>
+Main> B.g 42
+85.0
+Main> B.g 42
+85.0
+Main> B.g 42
+85.0
+Main>
+Main> -- swap A2 for A, compile & reload
+Main> :! cp A2.hs A.hs
+Main> :! $HC $HC_OPTS -no-recomp -c A.hs
+Main> :reload
+Ok, modules loaded: Main, C, B, A.
+Main> -- the system should ignore the compiled version and compile its own.
+Main>
+Main> B.g 42
+46
+Main> B.g 42
+46
+Main> B.g 42
+46
+Main>
+Main> -- pick up newly compiled A
+Main> :load D
+Ok, modules loaded: Main, C, B, A.
+Main>
+Main> B.g 42
+46
+Main> B.g 42
+46
+Main> B.g 42
+46
+Main>
+Main> -- remove A.o: system should recompile A
+Main> :! rm A.o
+Main> :reload
+Ok, modules loaded: Main, C, B, A.
+Main>
+Main> B.g 42
+46
+Main> B.g 42
+46
+Main> B.g 42
+46
+Main> Leaving GHCi.
--- /dev/null
+module Main(main,a) where
+
+import B
+import C
+
+main = print (a 42)
+
+a x = b x + c x
--- /dev/null
+module B where
+
+import D
+
+b x = d x
--- /dev/null
+module C where
+
+import D
+
+c x = d x
--- /dev/null
+module D where
+
+-- data types and an instance
+data D a = A Int | B Float deriving Eq
+newtype N a = N Double
+type T a = (Int,Double)
+
+-- a class
+class C a where c :: a -> Int
+
+-- a function
+d :: Float -> Float
+d x = x / 3
--- /dev/null
+module D where
+
+-- data types and an instance
+data D a = A Int | B Float deriving Eq
+newtype N a = N Double
+type T a = (Int,Double)
+
+-- a class
+class C a where c :: a -> Int
+
+-- a function
+d :: Int -> Int
+d x = x * 2
--- /dev/null
+module D where
+
+-- data types and an instance
+data D a = A Int | B Float deriving Eq
+newtype N a = N Double
+type T a = (Int,Double)
+
+-- a class
+class C a where c :: a -> Int
+
+-- a function
+d :: Float -> Float
+d x = x / 3
--- /dev/null
+#-----------------------------------------------------------------------------
+# $Id: Makefile,v 1.1 2001/03/01 15:36:21 simonmar Exp $
+
+TOP = ../..
+include $(TOP)/mk/boilerplate.mk
+
+include $(TOP)/mk/ghci.mk
--- /dev/null
+-- A small multi-module program, with 4 modules, Main, B, C, D. B & C
+-- depend on D, and A depends on B & C.
+--
+-- This test will try various combinations of compiled and interpreted
+-- versions of each module, and make sure each combination behaves
+-- sensibly.
+
+-- clean up
+:! rm *.o *.hi
+:unset +s
+:! cp D1.hs D.hs
+
+:load A
+:type a
+a 42
+
+-- sigh; sleep 1, because the comp manager only stores times in seconds
+:! sleep 1; cp D2.hs D.hs
+:reload
+:type (Main.a,B.b,C.c,D.d)
+a 42
+
+-- compile D, check that :reload doesn't pick it up
+:! $HC $HC_OPTS -c D.hs
+:reload
+:type (Main.a,B.b,C.c,D.d)
+a 42
+
+-- pick up the compiled D now, with :load
+:load A
+:type (Main.a,B.b,C.c,D.d)
+a 42
+
+-- D,C compiled
+:! $HC $HC_OPTS -c C.hs
+:load A
+:type (Main.a,B.b,C.c,D.d)
+a 42
+
+-- D,C,B compiled
+:! $HC $HC_OPTS -c B.hs
+:load A
+:type (Main.a,B.b,C.c,D.d)
+a 42
+
+-- D,C,B,A compiled
+:! $HC $HC_OPTS -c A.hs
+:load A
+:type (Main.a,B.b,C.c,D.d)
+a 42
+
+-- D,C,A compiled (better not use A.o)
+:load A
+:type (Main.a,B.b,C.c,D.d)
+a 42
+
+-- D,A compiled (better not use A.o)
+:! rm C.o
+:load A
+:type (Main.a,B.b,C.c,D.d)
+a 42
+
+-- A compiled (better not use A.o)
+:! rm D.o
+:load A
+:type (Main.a,B.b,C.c,D.d)
+a 42
+
+-- A,B,C compiled (better not use A.o, B.o, C.o)
+:! $HC $HC_OPTS --make A
+:! rm D.o
+:type (Main.a,B.b,C.c,D.d)
+a 42
--- /dev/null
+Compiling D (D.hs)
+Compiling C (C.hs)
+Compiling B (B.hs)
+Compiling Main (A.hs)
+Compiling D (D.hs)
+Compiling C (C.hs)
+Compiling B (B.hs)
+Compiling Main (A.hs)
+Skipping D (D.hs)
+ (using D.o)
+Compiling C (C.hs)
+Compiling B (B.hs)
+Compiling Main (A.hs)
+Skipping D (D.hs)
+ (using D.o)
+Skipping C (C.hs)
+ (using C.o)
+Compiling B (B.hs)
+Compiling Main (A.hs)
+Skipping D (D.hs)
+ (using D.o)
+Skipping C (C.hs)
+ (using C.o)
+Skipping B (B.hs)
+ (using B.o)
+Compiling Main (A.hs)
+Skipping D (D.hs)
+ (using D.o)
+Skipping C (C.hs)
+ (using C.o)
+Skipping B (B.hs)
+ (using B.o)
+Skipping Main (A.hs)
+ (using ./A.o)
+Skipping D (D.hs)
+ (using D.o)
+Skipping C (C.hs)
+ (using C.o)
+Skipping B (B.hs)
+ (using B.o)
+Skipping Main (A.hs)
+ (using ./A.o)
+Skipping D (D.hs)
+ (using D.o)
+Compiling C (C.hs)
+Skipping B (B.hs)
+ (using B.o)
+Compiling Main (A.hs)
+Compiling D (D.hs)
+Compiling C (C.hs)
+Compiling B (B.hs)
+Compiling Main (A.hs)
+ghc: chasing modules from: A
+Compiling D (D.hs)
+Compiling C (C.hs)
+Compiling B (B.hs)
+Compiling Main (A.hs)
+ghc: linking ...
--- /dev/null
+ ___ ___ _
+ / _ \ /\ /\/ __(_)
+ / /_\// /_/ / / | | GHC Interactive, version 4.11, For Haskell 98.
+/ /_\\/ __ / /___| | http://www.haskell.org/ghc/
+\____/\/ /_/\____/|_| Type :? for help.
+
+Loading package std ... linking ... done.
+Prelude> -- A small multi-module program, with 4 modules, Main, B, C, D. B & C
+Prelude> -- depend on D, and A depends on B & C.
+Prelude> --
+Prelude> -- This test will try various combinations of compiled and interpreted
+Prelude> -- versions of each module, and make sure each combination behaves
+Prelude> -- sensibly.
+Prelude>
+Prelude> -- clean up
+Prelude> :! rm *.o *.hi
+Prelude> :unset +s
+Prelude> :! cp D1.hs D.hs
+Prelude>
+Prelude> :load A
+Ok, modules loaded: Main, B, C, D.
+Main> :type a
+Int -> Int
+Main> a 42
+168
+Main>
+Main> -- sigh; sleep 1, because the comp manager only stores times in seconds
+Main> :! sleep 1; cp D2.hs D.hs
+Main> :reload
+Ok, modules loaded: Main, B, C, D.
+Main> :type (Main.a,B.b,C.c,D.d)
+(Float -> Float, Float -> Float, Float -> Float, Float -> Float)
+Main> a 42
+28.0
+Main>
+Main> -- compile D, check that :reload doesn't pick it up
+Main> :! $HC $HC_OPTS -c D.hs
+Main> :reload
+Ok, modules loaded: Main, B, C, D.
+Main> :type (Main.a,B.b,C.c,D.d)
+(Float -> Float, Float -> Float, Float -> Float, Float -> Float)
+Main> a 42
+28.0
+Main>
+Main> -- pick up the compiled D now, with :load
+Main> :load A
+Ok, modules loaded: Main, B, C, D.
+Main> :type (Main.a,B.b,C.c,D.d)
+(Float -> Float, Float -> Float, Float -> Float, Float -> Float)
+Main> a 42
+28.0
+Main>
+Main> -- D,C compiled
+Main> :! $HC $HC_OPTS -c C.hs
+Main> :load A
+Ok, modules loaded: Main, B, C, D.
+Main> :type (Main.a,B.b,C.c,D.d)
+(Float -> Float, Float -> Float, Float -> Float, Float -> Float)
+Main> a 42
+28.0
+Main>
+Main> -- D,C,B compiled
+Main> :! $HC $HC_OPTS -c B.hs
+Main> :load A
+Ok, modules loaded: Main, B, C, D.
+Main> :type (Main.a,B.b,C.c,D.d)
+(Float -> Float, Float -> Float, Float -> Float, Float -> Float)
+Main> a 42
+28.0
+Main>
+Main> -- D,C,B,A compiled
+Main> :! $HC $HC_OPTS -c A.hs
+Main> :load A
+Ok, modules loaded: Main, B, C, D.
+Main> :type (Main.a,B.b,C.c,D.d)
+(PrelFloat.Float -> PrelFloat.Float,
+ PrelFloat.Float -> PrelFloat.Float,
+ PrelFloat.Float -> PrelFloat.Float,
+ PrelFloat.Float -> PrelFloat.Float)
+Main> a 42
+28.0
+Main>
+Main> -- D,C,A compiled (better not use A.o)
+Main> :load A
+Ok, modules loaded: Main, B, C, D.
+Main> :type (Main.a,B.b,C.c,D.d)
+(PrelFloat.Float -> PrelFloat.Float,
+ PrelFloat.Float -> PrelFloat.Float,
+ PrelFloat.Float -> PrelFloat.Float,
+ PrelFloat.Float -> PrelFloat.Float)
+Main> a 42
+28.0
+Main>
+Main> -- D,A compiled (better not use A.o)
+Main> :! rm C.o
+Main> :load A
+Ok, modules loaded: Main, B, C, D.
+Main> :type (Main.a,B.b,C.c,D.d)
+(Float -> Float, Float -> Float, Float -> Float, Float -> Float)
+Main> a 42
+28.0
+Main>
+Main> -- A compiled (better not use A.o)
+Main> :! rm D.o
+Main> :load A
+Ok, modules loaded: Main, B, C, D.
+Main> :type (Main.a,B.b,C.c,D.d)
+(Float -> Float, Float -> Float, Float -> Float, Float -> Float)
+Main> a 42
+28.0
+Main>
+Main> -- A,B,C compiled (better not use A.o, B.o, C.o)
+Main> :! $HC $HC_OPTS --make A
+Main> :! rm D.o
+Main> :type (Main.a,B.b,C.c,D.d)
+(Float -> Float, Float -> Float, Float -> Float, Float -> Float)
+Main> a 42
+28.0
+Main> Leaving GHCi.