handleEvalStatus
  :: HscEnv -> EvalStatus [HValueRef]
  -> IO (EvalStatus_ [ForeignHValue] [HValueRef])
handleEvalStatus hsc_env status =
  case status of
    EvalBreak a b c d e -> return (EvalBreak a b c d e)
    EvalComplete alloc res ->
      EvalComplete alloc <$> addFinalizer res
 where
  addFinalizer (EvalException bytes e) = do
    printBytes bytes
    return (EvalException bytes e)
  addFinalizer (EvalSuccess bytes rs) = do
    printBytes bytes
    EvalSuccess bytes <$> mapM (mkFinalizedHValue hsc_env) rs
handleEvalStatus
  :: HscEnv -> EvalStatus [HValueRef]
  -> IO (EvalStatus_ [ForeignHValue] [HValueRef])
handleEvalStatus hsc_env status =
  case status of
    EvalBreak a b c d e -> return (EvalBreak a b c d e)
    EvalComplete alloc res ->
      EvalComplete alloc <$> addFinalizer res
 where
  addFinalizer (EvalException bytes e) = do
    printBytes bytes
    return (EvalException bytes e)
  addFinalizer (EvalSuccess bytes rs) = do
    printBytes bytes
    EvalSuccess bytes <$> mapM (mkFinalizedHValue hsc_env) rs
handleEvalStatus hsc_env status =
  case status of
    EvalBreak a b c d e -> return (EvalBreak a b c d e)
    EvalComplete alloc res ->
      EvalComplete alloc <$> addFinalizer res
 where
  addFinalizer (EvalException bytes e) = do
    printBytes bytes
    return (EvalException bytes e)
  addFinalizer (EvalSuccess bytes rs) = do
    printBytes bytes
    EvalSuccess bytes <$> mapM (mkFinalizedHValue hsc_env) rs