summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_run/tcrun014.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/typecheck/should_run/tcrun014.hs')
-rw-r--r--testsuite/tests/typecheck/should_run/tcrun014.hs22
1 files changed, 22 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_run/tcrun014.hs b/testsuite/tests/typecheck/should_run/tcrun014.hs
new file mode 100644
index 0000000000..751e9aa5bf
--- /dev/null
+++ b/testsuite/tests/typecheck/should_run/tcrun014.hs
@@ -0,0 +1,22 @@
+-- !!! Newtypes
+
+-- This one made ghc 5.01 (after newtype squashing) fall over
+-- by generating Core code that contained a pattern match on
+-- the InPE data constructor (which doesn't exist)
+
+module Main where
+
+
+data Expr e = One e | Many [e]
+newtype PExpr a = InPE (Expr (PExpr a), Int)
+
+one :: Int -> PExpr e -> PExpr e
+one l x = InPE (One (plus1 x), l)
+
+plus1 :: PExpr a -> PExpr a
+plus1 x@(InPE (_, loc)) = InPE (Many [plus1 x], loc)
+
+get :: PExpr e -> Int
+get (InPE (_,l)) = l
+
+main = print (get (plus1 (InPE (Many [], 0))))