summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_run/tcrun015.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/typecheck/should_run/tcrun015.hs')
-rw-r--r--testsuite/tests/typecheck/should_run/tcrun015.hs21
1 files changed, 21 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_run/tcrun015.hs b/testsuite/tests/typecheck/should_run/tcrun015.hs
new file mode 100644
index 0000000000..a75e7e88d5
--- /dev/null
+++ b/testsuite/tests/typecheck/should_run/tcrun015.hs
@@ -0,0 +1,21 @@
+-- !!! Newtypes
+
+-- A variation of tc014 that Sigbjorn said failed
+
+module Main where
+
+data Expr a b = One a | Many [b]
+newtype Pat a = InP (Expr a (Pat a), Int)
+newtype PExpr a = InPE (Expr a (PExpr a), Int)
+
+plus1 x@(InPE (_, loc)) = InPE (Many [x], loc)
+one x l = InPE (One (plus1 x), l)
+
+outP (InP x) = x
+
+getPatNames p
+ = case outP p of
+ (One n, _) -> [n]
+ (Many ps, _) -> concatMap getPatNames ps
+
+main = print (take 10 (map getPatNames (repeat (InP (One "n", 1)))))