Skip to content

Commit

Permalink
#415, back out the last pieces of GHC 8.0-rc3 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
ndmitchell committed May 27, 2017
1 parent ec5d038 commit 37a3199
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/Development/Shake/Internal/Core/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,14 @@ newtype RAW ro rw a = RAW {fromRAW :: ReaderT (S ro rw) (ContT () IO) a}
type Capture a = (a -> IO ()) -> IO ()


-- See https://ghc.haskell.org/trac/ghc/ticket/11555
catchSafe :: IO a -> (SomeException -> IO a) -> IO a
catchSafe = catch_

-- | Run and then call a continuation.
runRAW :: ro -> rw -> RAW ro rw a -> Capture (Either SomeException a)
runRAW ro rw m k = do
rww <- newIORef rw
handler <- newIORef $ k . Left
-- see https://ghc.haskell.org/trac/ghc/ticket/11555
fromRAW m `runReaderT` S handler ro rww `runContT` (k . Right)
`catchSafe` \e -> ($ e) =<< readIORef handler
`catch_` \e -> ($ e) =<< readIORef handler


---------------------------------------------------------------------
Expand Down Expand Up @@ -87,7 +83,7 @@ catchRAW m hdl = RAW $ ReaderT $ \s -> ContT $ \k -> do
old <- readIORef $ handler s
writeIORef (handler s) $ \e -> do
writeIORef (handler s) old
fromRAW (hdl e) `runReaderT` s `runContT` k `catchSafe`
fromRAW (hdl e) `runReaderT` s `runContT` k `catch_`
\e -> ($ e) =<< readIORef (handler s)
fromRAW m `runReaderT` s `runContT` \v -> do
writeIORef (handler s) old
Expand Down Expand Up @@ -124,5 +120,5 @@ captureRAW f = RAW $ ReaderT $ \s -> ContT $ \k -> do
Left e -> old e
Right v -> do
writeIORef (handler s) old
k v `catchSafe` \e -> ($ e) =<< readIORef (handler s)
k v `catch_` \e -> ($ e) =<< readIORef (handler s)
writeIORef (handler s) throwIO

0 comments on commit 37a3199

Please sign in to comment.