summaryrefslogtreecommitdiff
path: root/testsuite/tests/deriving/should_run/drvrun005.hs
diff options
context:
space:
mode:
authorDavid Terei <davidterei@gmail.com>2011-07-20 11:09:03 -0700
committerDavid Terei <davidterei@gmail.com>2011-07-20 11:26:35 -0700
commit16514f272fb42af6e9c7674a9bd6c9dce369231f (patch)
treee4f332b45fe65e2a7a2451be5674f887b42bf199 /testsuite/tests/deriving/should_run/drvrun005.hs
parentebd422aed41048476aa61dd4c520d43becd78682 (diff)
downloadhaskell-16514f272fb42af6e9c7674a9bd6c9dce369231f.tar.gz
Move tests from tests/ghc-regress/* to just tests/*
Diffstat (limited to 'testsuite/tests/deriving/should_run/drvrun005.hs')
-rw-r--r--testsuite/tests/deriving/should_run/drvrun005.hs27
1 files changed, 27 insertions, 0 deletions
diff --git a/testsuite/tests/deriving/should_run/drvrun005.hs b/testsuite/tests/deriving/should_run/drvrun005.hs
new file mode 100644
index 0000000000..a4ef060a6a
--- /dev/null
+++ b/testsuite/tests/deriving/should_run/drvrun005.hs
@@ -0,0 +1,27 @@
+module Main where
+
+{-
+ If a fixity declaration hasn't been supplied for
+ an operator, it is defaulted to being "infixl 9".
+
+ OLD: The derived Read instances for data types containing
+ left-assoc constructors produces code that causes
+ non-termination if you use 'read' to evaluate them
+ ( (head (reads x)) is cool tho.)
+
+ ==> The inferred assoc for :++ below left & the derived
+ Read instance should fail to terminate (with ghc-4.xx,
+ this is exemplified by having the stack overflow.)
+
+ NEW: the new H98 spec says that we ignore associativity when
+ parsing, so it terminates fine
+-}
+-- infixl 9 :++
+data T = T1 | T :++ T deriving (Eq,Show, Read)
+
+t :: T
+t = read "T1"
+
+main = do
+ print ((fst (head (reads "T1"))) :: T)
+ print t