diff options
Diffstat (limited to 'testsuite/tests/mdo/should_compile/mdo002.hs')
-rw-r--r-- | testsuite/tests/mdo/should_compile/mdo002.hs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/testsuite/tests/mdo/should_compile/mdo002.hs b/testsuite/tests/mdo/should_compile/mdo002.hs new file mode 100644 index 0000000000..dc33595590 --- /dev/null +++ b/testsuite/tests/mdo/should_compile/mdo002.hs @@ -0,0 +1,23 @@ +{-# OPTIONS -XRecursiveDo #-} + +-- test of user defined instance of MonadFix + +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 + +instance MonadFix X where + mfix f = fix (f . unX) + where unX ~(X x) = x + +z :: X [Int] +z = mdo x <- return (1:x) + return (take 4 x) + +main = print z |