Improve error messages around kind mismatches.
[ghc.git] / testsuite / tests / typecheck / should_fail / T8603.hs
1 module T8603 where
2
3 import Control.Monad
4 import Data.Functor
5 import Control.Monad.Trans.Class( lift )
6 import Control.Monad.Trans.State( StateT )
7
8 newtype RV a = RV { getPDF :: [(Rational,a)] } deriving (Show, Eq)
9
10 instance Functor RV where
11 fmap f = RV . map (\(x,y) -> (x, f y)) . getPDF
12
13 instance Applicative RV where
14 pure = return
15 (<*>) = ap
16
17 instance Monad RV where
18 return x = RV [(1,x)]
19 rv >>= f = RV $
20 do (p,a) <- getPDF rv
21 guard (p > 0)
22 (q,b) <- getPDF $ f a
23 guard (q > 0)
24 return (p*q, b)
25
26 type RVState s a = StateT s RV a
27
28 uniform :: [a] -> RV a
29 uniform x = RV [(1/fromIntegral (length x), y) | y <- x]
30
31 testRVState1 :: RVState s Bool
32 testRVState1
33 = do prize <- lift uniform [1,2,3]
34 return False
35
36 -- lift :: (MonadTrans t, Monad m) => m a -> t m a