summaryrefslogtreecommitdiff
path: root/testsuite/tests/mdo/should_fail/mdofail004.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/mdo/should_fail/mdofail004.hs')
-rw-r--r--testsuite/tests/mdo/should_fail/mdofail004.hs22
1 files changed, 22 insertions, 0 deletions
diff --git a/testsuite/tests/mdo/should_fail/mdofail004.hs b/testsuite/tests/mdo/should_fail/mdofail004.hs
new file mode 100644
index 0000000000..37cd757312
--- /dev/null
+++ b/testsuite/tests/mdo/should_fail/mdofail004.hs
@@ -0,0 +1,22 @@
+{-# OPTIONS -XRecursiveDo #-}
+
+-- OLD: mdo requires MonadFix instance, even
+-- if no recursion is present
+
+-- Dec 2010: Small change of behaviour
+-- MonadFix is only required if recursion is present
+
+module Main (main) where
+
+import Control.Monad.Fix
+
+data X a = X a deriving Show
+
+instance Monad X where
+ return = X
+ (X a) >>= f = f a
+
+z :: X [Int]
+z = mdo { a <- return 1; return [a] }
+
+main = print z