Ticket #1485: MaybeBug.hs

File MaybeBug.hs, 667 bytes (added by iampure@…, 7 years ago)

File showing possible bug (at least a large limitation) in ghc 6.6

Line 
1{-# OPTIONS_GHC -fno-monomorphism-restriction -fallow-undecidable-instances #-}
2import Data.STRef
3import Control.Monad.ST
4
5class Monad m => MonadST s m | m -> s where
6     liftST :: ST s a -> m a
7
8val :: (MonadST s m) => STRef s a -> m a
9val = undefined
10
11-- with type signature zork works, without it suggests to use -fno-monomorphism-restriction, i.e. it doesn't work
12zork :: (MonadST s m) =>  STRef s t -> m ()
13zork ref_t = do
14  t <- val ref_t
15  (cond False
16    (return ())
17    (return ()))
18
19class Cond c a  | c -> a  where
20 cond:: c -> a -> a -> a
21
22instance (Monad m) => Cond (m Bool) (m t)  where
23 cond = undefined
24
25instance Cond Bool t where
26 cond = undefined