-- | Helper which lifts IO actions into 'SimpleSSH'. This is used all over the place.
liftIOEither :: IO (Either SimpleSSHError a) -> SimpleSSH a
liftIOEither ioAction = do
  eRes <- liftIO ioAction
  case eRes of
    Left err  -> throwError err
    Right res -> return res

-- | Helper which interprets a result coming from C.
--
-- Functions in the C part return pointers to a structure mimicking 'Either'.
liftIOEither :: IO (Either SimpleSSHError a) -> SimpleSSH a
liftIOEither ioAction = do
  eRes <- liftIO ioAction
  case eRes of
    Left err  -> throwError err
    Right res -> return res

-- | Helper which interprets a result coming from C.
--
-- Functions in the C part return pointers to a structure mimicking 'Either'.
liftIOEither ioAction = do
  eRes <- liftIO ioAction
  case eRes of
    Left err  -> throwError err
    Right res -> return res

-- | Helper which interprets a result coming from C.
--
-- Functions in the C part return pointers to a structure mimicking 'Either'.