Rodrigo Mesquita pushed to branch wip/romes/async-rpc at Glasgow Haskell Compiler / GHC

Commits:

1 changed file:

Changes:

  • compiler/GHC/Runtime/Interpreter/Process.hs
    ... ... @@ -3,6 +3,7 @@ module GHC.Runtime.Interpreter.Process
    3 3
       -- * Message API
    
    4 4
         Message(..)
    
    5 5
       , sendMessage
    
    6
    +  , RemoteCallFailed(..)
    
    6 7
       )
    
    7 8
     where
    
    8 9
     
    
    ... ... @@ -18,12 +19,14 @@ import GHC.Utils.Exception as Ex
    18 19
     import Data.Binary
    
    19 20
     import System.Exit
    
    20 21
     import System.Process
    
    21
    -import Data.Bifunctor
    
    22 22
     
    
    23 23
     -- -----------------------------------------------------------------------------
    
    24 24
     -- Top-level Message API
    
    25 25
     
    
    26 26
     -- | Send a message to the interpreter and expect a response, blocking until it arrives.
    
    27
    +--
    
    28
    +-- Throws 'RemoteCallFailed' if the remote call threw an exception in the
    
    29
    +-- external interpreter
    
    27 30
     sendMessage :: Binary a => ExtInterpInstance d -> Message a -> IO a
    
    28 31
     sendMessage i msg = unwrapRight =<<
    
    29 32
       remoteCall (interpPipe proc) msg
    
    ... ... @@ -33,10 +36,7 @@ sendMessage i msg = unwrapRight =<<
    33 36
         unwrapRight :: Either SomeException b -> IO b
    
    34 37
         unwrapRight (Right a) = pure a
    
    35 38
         unwrapRight (Left er) = do
    
    36
    -      let ex = RemoteCallFailed er
    
    37
    -      unwrapRight . bimap (addExceptionContext (WhileHandling (SomeException ex))) id
    
    38
    -        =<< remoteCall (interpPipe proc) Shutdown
    
    39
    -      throwIO ex
    
    39
    +      throwIO (RemoteCallFailed er)
    
    40 40
     
    
    41 41
     handleInterpProcessFailure :: InterpProcess -> SomeException -> IO a
    
    42 42
     handleInterpProcessFailure i e = do