summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_fail/T12170a.hs
blob: 6783cd0a44e330863183ed773502c50b3e5c2d65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fdefer-out-of-scope-variables #-}

module T12170a where

-- import Control.Monad  -- comment this out to cause error
import Data.IORef

class MonadRef m where
    type Ref m :: * -> *
    newRef :: a -> m (Ref m a)
    readRef :: Ref m a -> m a

instance MonadRef IO where
    type Ref IO = IORef
    newRef = newIORef
    readRef = readIORef

foo :: IO ()
foo = newRef (pure ()) >>= join . readRef