summaryrefslogtreecommitdiff
path: root/testsuite/tests/simplCore/should_compile/simpl005.hs
blob: abf98a30d2d565a4053daf434ea94b6d74511af0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
-- !!! CPR on newtype with polymorphic argument

{-# OPTIONS -O #-}

module ShouldCompile where

data StateM m s a = STM (s -> m (a,s)) 

instance Functor m => Functor (StateM m s) where
  fmap f (STM xs) =  STM (\s -> fmap (\ (x,s') -> (f x, s')) 
                    		     (xs s)                                
		         )
{-	With GHC 4.04 (first release) this program gave:

  panic! (the `impossible' happened):
          mk_cpr_let: not a product
      forall a{-ruq-} b{-rur-}.
      (a{-ruq-} -> b{-rur-})
      -> MonadLibrary.StateM{-r2o,x-} m{-a30Y-} s{-a30Z-} a{-ruq-}
      -> MonadLibrary.StateM{-r2o,x-} m{-a30Y-} s{-a30Z-} b{-rur-}

 The reason: 'Functor' is a newtype, whose element is a for-all type.

	newtype Functor f = Functor (forall a,b.  (a->b) -> f a -> f b)
-}