Generalized `fromInput` and `toOutput` to use `MonadIO`