23725c1e4b8e603de3565a8884deda13e85f0e97
[ghc.git] / testsuite / tests / warnings / should_compile / T11128.hs
1 {-# LANGUAGE DeriveFunctor #-}
2 {-# OPTIONS_GHC -fwarn-noncanonical-monad-instances #-}
3
4 -- | Test noncanonical-monad-instances warnings
5 module T11128 where
6
7 import Control.Applicative as A
8 import Control.Monad as M
9
10 ----------------------------------------------------------------------------
11 -- minimal definition
12
13 data T0 a = T0 a deriving Functor
14
15 instance A.Applicative T0 where
16 pure = T0
17 (<*>) = M.ap
18
19 instance M.Monad T0 where
20 (>>=) = undefined
21
22 ----------------------------------------------------------------------------
23 -- trigger all 4 warnings
24
25 data T1 a = T1 a deriving Functor
26
27 instance A.Applicative T1 where
28 pure = return
29 (<*>) = M.ap
30 (*>) = (M.>>)
31
32 instance M.Monad T1 where
33 (>>=) = undefined
34 return = T1
35 (>>) = undefined
36
37 ----------------------------------------------------------------------------
38 -- backward compat canonical definition
39
40 data T2 a = T2 a deriving Functor
41
42 instance Applicative T2 where
43 pure = T2
44 (<*>) = ap
45 (*>) = undefined
46
47 instance M.Monad T2 where
48 (>>=) = undefined
49 return = pure
50 (>>) = (*>)