[project @ 2000-05-16 14:04:25 by rrt]
[ghc-hetmet.git] / ghc / tests / simplCore / should_compile / simpl005.hs
1 -- !!! CPR on newtype with polymorphic argument
2
3 {-# OPTIONS -O #-}
4
5 module ShouldCompile where
6
7 data StateM m s a = STM (s -> m (a,s)) 
8
9 instance Functor m => Functor (StateM m s) where
10   fmap f (STM xs) =  STM (\s -> fmap (\ (x,s') -> (f x, s')) 
11                                      (xs s)                                
12                          )
13 {-      With GHC 4.04 (first release) this program gave:
14
15   panic! (the `impossible' happened):
16           mk_cpr_let: not a product
17       forall a{-ruq-} b{-rur-}.
18       (a{-ruq-} -> b{-rur-})
19       -> MonadLibrary.StateM{-r2o,x-} m{-a30Y-} s{-a30Z-} a{-ruq-}
20       -> MonadLibrary.StateM{-r2o,x-} m{-a30Y-} s{-a30Z-} b{-rur-}
21
22  The reason: 'Functor' is a newtype, whose element is a for-all type.
23
24         newtype Functor f = Functor (forall a,b.  (a->b) -> f a -> f b)
25 -}