Merge pull request #246 from input-output-hk/coot/trace-pr-review
PR review comments
PR review comments
io-sim improvments
Asynchronous exceptions might be coming from outside of a simulation, for example when using QuickCheck's `within` function.
An exception provided as an argument to `throwIO` or `throwTo` might be a bottom value itself. This is fine in general, since `throwIO` and `throwTo` are lazy, it's a `catch` handler or the top level handler role to evaluate them. `IOSim` supports this, but we need to away to display trace in presence of bottoms in `EventThrow` and `EventThrowTo`. We use `unsafePerformIO` to evaluate `show e` to NF before including it the trace. With the included patch the trace of ```haskell sim :: IOSim s () sim = throwIO (error "bottom") ``` will contain ``` Throw - error evaluating exception: bottom ``` in `ppTrace` output.
This patch makes `say` behave similar to how `putStrLn` does: evaluate its argument to `NF` and throw an exception if evaluation fails. The same applies to the `MonadSay` instance of the `STM (IOSim s)` monad. For `traceM` and `traceSTM` we move evaluation from these functions, to the simulators (IOSim, IOSimPOR), which allows to throw an exception within the simulator.
Added flushEventLog to MonadEventlog
Asynchronous exceptions might be coming from outside of a simulation, for example when using QuickCheck's `within` function.
An exception provided as an argument to `throwIO` or `throwTo` might be a bottom value itself. This is fine in general, since `throwIO` and `throwTo` are lazy, it's a `catch` handler or the top level handler role to evaluate them. `IOSim` supports this, but we need to away to display trace in presence of bottoms in `EventThrow` and `EventThrowTo`. We use `unsafePerformIO` to evaluate `show e` to NF before including it the trace. With the included patch the trace of ```haskell sim :: IOSim s () sim = throwIO (error "bottom") ``` will contain ``` Throw - error evaluating exception: bottom ``` in `ppTrace` output.
This patch makes `say` behave similar to how `putStrLn` does: evaluate its argument to `NF` and throw an exception if evaluation fails. The same applies to the `MonadSay` instance of the `STM (IOSim s)` monad. For `traceM` and `traceSTM` we move evaluation from these functions, to the simulators (IOSim, IOSimPOR), which allows to throw an exception within the simulator.