1 -- !!! CPR on newtype with polymorphic argument
5 module ShouldCompile where
7 data StateM m s a = STM (s -> m (a,s))
9 instance Functor m => Functor (StateM m s) where
10 fmap f (STM xs) = STM (\s -> fmap (\ (x,s') -> (f x, s'))
13 {- With GHC 4.04 (first release) this program gave:
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-}
22 The reason: 'Functor' is a newtype, whose element is a for-all type.
24 newtype Functor f = Functor (forall a,b. (a->b) -> f a -> f b)