diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2012-10-12 13:59:07 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2012-10-12 13:59:07 +0100 |
commit | ab57afefeb9cb6aa1bf29e1db06bec9e399e0002 (patch) | |
tree | 4a3aee323b4a220fffafca1ba53909739d1c482c /testsuite/tests | |
parent | 75183ed9e51b5e2d25d5ca74037481f1812dfeba (diff) | |
download | haskell-ab57afefeb9cb6aa1bf29e1db06bec9e399e0002.tar.gz |
Test Trac #5751
Diffstat (limited to 'testsuite/tests')
-rw-r--r-- | testsuite/tests/typecheck/should_run/T5751.hs | 38 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_run/T5751.stdout | 3 | ||||
-rwxr-xr-x | testsuite/tests/typecheck/should_run/all.T | 1 |
3 files changed, 42 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_run/T5751.hs b/testsuite/tests/typecheck/should_run/T5751.hs new file mode 100644 index 0000000000..f620d8fb63 --- /dev/null +++ b/testsuite/tests/typecheck/should_run/T5751.hs @@ -0,0 +1,38 @@ +{-# LANGUAGE FlexibleContexts, FlexibleInstances, GeneralizedNewtypeDeriving, OverlappingInstances, UndecidableInstances #-} +module Main where + +class (Monad m) => MonadIO m where + -- | Lift a computation from the 'IO' monad. + liftIO :: IO a -> m a + +instance MonadIO IO where + liftIO = id + +class XMLGenerator m where + genElement :: (Maybe String, String) -> m () + +newtype IdentityT m a = IdentityT { runIdentityT :: m a } + deriving (Monad, MonadIO) + +instance (MonadIO m) => (XMLGenerator (IdentityT m)) where + genElement _ = liftIO $ putStrLn "in genElement" + +main :: IO () +main = + do runIdentityT web + putStrLn "done." + +class (Widgets x) => MonadRender x +class (XMLGenerator m) => Widgets m +-- instance Widgets (IdentityT IO) -- if you uncomment this, it will work +instance MonadRender m => Widgets m +instance MonadRender (IdentityT IO) + +web :: ( MonadIO m + , Widgets m + , XMLGenerator m + ) => m () +web = + do liftIO $ putStrLn "before" + genElement (Nothing, "p") + return () diff --git a/testsuite/tests/typecheck/should_run/T5751.stdout b/testsuite/tests/typecheck/should_run/T5751.stdout new file mode 100644 index 0000000000..0686f3cb49 --- /dev/null +++ b/testsuite/tests/typecheck/should_run/T5751.stdout @@ -0,0 +1,3 @@ +before +in genElement +done. diff --git a/testsuite/tests/typecheck/should_run/all.T b/testsuite/tests/typecheck/should_run/all.T index 709bb32cbc..ec1fcf65f1 100755 --- a/testsuite/tests/typecheck/should_run/all.T +++ b/testsuite/tests/typecheck/should_run/all.T @@ -97,3 +97,4 @@ test('T5573b', compose(omit_ways(['ghci']),only_compiler_types(['ghc'])), compil test('T7023', normal, compile_and_run, ['']) test('T7126', normal, compile_and_run, ['']) test('T6117', expect_broken(6117), compile_and_run, ['']) +test('T5751', normal, compile_and_run, ['']) |