Fundeps work even for unary type classes
[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 Monad RV where
14 return x = RV [(1,x)]
15 rv >>= f = RV $
16 do (p,a) <- getPDF rv
17 guard (p > 0)
18 (q,b) <- getPDF $ f a
19 guard (q > 0)
20 return (p*q, b)
21
22 type RVState s a = StateT s RV a
23
24 uniform :: [a] -> RV a
25 uniform x = RV [(1/fromIntegral (length x), y) | y <- x]
26
27 testRVState1 :: RVState s Bool
28 testRVState1
29 = do prize <- lift uniform [1,2,3]
30 return False
31
32 -- lift :: (MonadTrans t, Monad m) => m a -> t m a