SCC analysis for instances as well as types/classes
[ghc.git] / testsuite / tests / typecheck / should_compile / tc183.hs
1 {-# OPTIONS_GHC -fno-warn-redundant-constraints #-}
2 {-# LANGUAGE ExistentialQuantification, RankNTypes #-}
3
4 -- An interesting interaction of universals and existentials, prompted by
5 -- http://www.haskell.org/pipermail/haskell-cafe/2004-October/007160.html
6 --
7 -- Note the non-nested pattern-match in runProg; tcfail126 checks the
8 -- nested pattern match
9
10 module Foo where
11
12 import Control.Monad.Trans
13
14 data Bar m
15 = forall t. (MonadTrans t, Monad (t m))
16 => Bar (t m () -> m ()) (t m Int)
17
18 data Foo = Foo (forall m. Monad m => Bar m)
19
20 runProg :: Foo -> IO ()
21 runProg (Foo b) = case b of
22 Bar run op -> run (prog op)
23 -- You can't say runProg (Foo (Bar run op));
24 -- see tcfail126
25
26 prog :: (MonadTrans t, Monad (t IO)) => a -> t IO ()
27 prog x = error "urk"