Commit 4c60e0dd authored by simonpj's avatar simonpj

[project @ 2004-10-20 11:31:47 by simonpj]

Add more pattern-match tests
parent 4543b6c5
......@@ -192,3 +192,4 @@ test('tc179', normal, compile, [''])
test('tc180', normal, compile, [''])
test('tc181', normal, compile, [''])
test('tc182', normal, compile, [''])
test('tc183', normal, compile, [''])
{-# OPTIONS -fglasgow-exts #-}
-- An interesting interaction of universals and existentials, prompted by
-- http://www.haskell.org/pipermail/haskell-cafe/2004-October/007160.html
--
-- Note the non-nested pattern-match in runProg; tcfail126 checks the
-- nested pattern match
module Foo where
import Control.Monad.Trans
data Bar m
= forall t. (MonadTrans t, Monad (t m))
=> Bar (t m () -> m ()) (t m Int)
data Foo = Foo (forall m. Monad m => Bar m)
runProg :: Foo -> IO ()
runProg (Foo b) = case b of
Bar run op -> run (prog op)
-- You can't say runProg (Foo (Bar run op));
-- see tcfail126
prog :: (MonadTrans t, Monad (t IO)) => a -> t IO ()
prog x = error "urk"
......@@ -111,3 +111,4 @@ test('tcfail122', normal, compile_fail, [''])
test('tcfail123', normal, compile_fail, [''])
test('tcfail124', normal, compile_fail, [''])
test('tcfail125', normal, compile_fail, [''])
test('tcfail126', normal, compile_fail, [''])
{-# OPTIONS -fglasgow-exts #-}
-- An interesting interaction of universals and existentials, prompted by
-- http://www.haskell.org/pipermail/haskell-cafe/2004-October/007160.html
--
-- Note the nested pattern-match in runProg; tc183 checks the
-- non-nested version
module Foo where
import Control.Monad.Trans
data Bar m
= forall t. (MonadTrans t, Monad (t m))
=> Bar (t m () -> m ()) (t m Int)
data Foo = Foo (forall m. Monad m => Bar m)
runProg :: Foo -> IO ()
runProg (Foo (Bar run op)) = run (prog op)
-- This nested match "ought" to work; because
-- runProg (Foo b) = case b of
-- Bar run op -> run (prog op)
-- does work. But the interactions with GADTs and
-- desugaring defeated me, and I removed (in GHC 6.4) the ability
-- to instantiate functions on the left
prog :: (MonadTrans t, Monad (t IO)) => a -> t IO ()
prog x = error "urk"
tcfail126.hs:20:14:
Couldn't match `forall (m :: * -> *). (Monad m) => Bar m' against `Bar m'
In the definition of `runProg': runProg (Foo (Bar run op)) = run (prog op)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment