summaryrefslogtreecommitdiff
path: root/testsuite/tests/mdo/should_fail/mdofail004.hs
blob: a313747e8ab39adbaa19daf913ec99a641a7140d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{-# 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

import Control.Applicative (Applicative(..))
import Control.Monad (liftM, ap)

data X a = X a deriving Show

instance Functor X where
    fmap = liftM

instance Applicative X where
    pure = X
    (<*>) = ap

instance Monad X where
  (X a) >>= f = f a

z :: X [Int]
z = mdo { a <- return 1; return [a] }

main = print z