summaryrefslogtreecommitdiff
path: root/testsuite/tests/simplCore/prog002
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/simplCore/prog002')
-rw-r--r--testsuite/tests/simplCore/prog002/Makefile3
-rw-r--r--testsuite/tests/simplCore/prog002/Simpl009Help.hs39
-rw-r--r--testsuite/tests/simplCore/prog002/simpl009.hs23
-rw-r--r--testsuite/tests/simplCore/prog002/test.T5
4 files changed, 70 insertions, 0 deletions
diff --git a/testsuite/tests/simplCore/prog002/Makefile b/testsuite/tests/simplCore/prog002/Makefile
new file mode 100644
index 0000000000..9101fbd40a
--- /dev/null
+++ b/testsuite/tests/simplCore/prog002/Makefile
@@ -0,0 +1,3 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/simplCore/prog002/Simpl009Help.hs b/testsuite/tests/simplCore/prog002/Simpl009Help.hs
new file mode 100644
index 0000000000..ac75943016
--- /dev/null
+++ b/testsuite/tests/simplCore/prog002/Simpl009Help.hs
@@ -0,0 +1,39 @@
+{-# LANGUAGE ScopedTypeVariables, RankNTypes #-}
+
+-- Helper for simpl009.hs (see comments there)
+
+module Simpl009Help where
+
+import Control.Monad
+
+newtype Parser s a
+ = Parser (forall res . (a -> [String] -> P s res) -> [String] -> P s res)
+
+data P s res
+ = Symbol (s -> P s res)
+ | Fail [String] [String]
+ | Result res (P s res)
+
+instance Monad (Parser s) where
+ return a = Parser (\fut -> fut a)
+
+ Parser f >>= k =
+ Parser (\fut -> f (\a -> let Parser g = k a in g fut))
+
+ fail s =
+ Parser (\fut exp -> Fail exp [s])
+
+instance MonadPlus (Parser s) where
+ mplus = error "urk"
+ mzero = Parser (\fut exp -> Fail exp [])
+
+lookAhead :: forall s. Parser s s
+lookAhead =
+ Parser (\fut exp -> Symbol (\c ->
+ feed c (fut c [])
+ ))
+ where
+ feed :: forall res. s -> P s res -> P s res
+ feed c (Symbol sym) = sym c
+ feed c (Result res fut) = Result res (feed c fut)
+ feed c p@(Fail _ _) = p
diff --git a/testsuite/tests/simplCore/prog002/simpl009.hs b/testsuite/tests/simplCore/prog002/simpl009.hs
new file mode 100644
index 0000000000..bac2bafbdb
--- /dev/null
+++ b/testsuite/tests/simplCore/prog002/simpl009.hs
@@ -0,0 +1,23 @@
+
+-- This one killed GHC 5.02 with a funResultTy panic
+-- The reason was that the simplifier was doing a
+-- case-of-case where the result had a polymorphic type.
+-- This in turn showed up because of a newtype (now
+-- transparent) with a forall inside it.
+--
+-- It's quite hard to tickle this one, hence the two-module setup.
+
+module FormParse where
+
+import Control.Monad
+import Simpl009Help
+
+identifier :: Parser Char Char
+identifier =
+ do c <- lookAhead
+ guard (c == 'a')
+ return c
+
+
+
+
diff --git a/testsuite/tests/simplCore/prog002/test.T b/testsuite/tests/simplCore/prog002/test.T
new file mode 100644
index 0000000000..1394874e16
--- /dev/null
+++ b/testsuite/tests/simplCore/prog002/test.T
@@ -0,0 +1,5 @@
+test('simplCore.prog002',
+ extra_clean(['Simpl009Help.hi', 'Simpl009Help.o',
+ 'simpl009.hi', 'simpl009.o']),
+ multimod_compile,
+ ['simpl009', '-v0'])