is ```private fun <E, T> Raise<E>.contramap(f: (T)...
# arrow
p
is
Copy code
private fun <E, T> Raise<E>.contramap(f: (T) -> E): Raise<T> = object : Raise<T> {
  override fun raise(e: T) = raise(f(e))
}
sane, assuming the mapped raise doesn't escape the bounds of the original raise?
y
It's sane yes, but
withError
is preferred, mostly because it can do it
inline
p
I'm storing a reference to the contramapped raise in a class (that lives entirely within the scope), otherwise I'd have used withError 🙂
y
Yeah that's fine then! We've had Raise implementations that basically did that (e.g. IorRaise), but I was keen to move away from that to prepare for context parameters (so that
recover
would work naturally and replace the Raise), however as an implementation it's absolutely fine
p