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