Inverts the context of a Result value such that Errors are transformed into Oks, and Oks are transformed into Errors. Does not touch the value inside of the Result.
This API is still experimental, so it may change or be removed in future versions. You should not rely on it for production applications.
forall a, b: (Result a b).() => Result b a
Inverts the context of a Result value such that Errors are transformed into Oks, and Oks are transformed into Errors. Does not touch the value inside of the Result.
const Result = require('folktale/result');
Result.Ok(1).swap();
// ==> Result.Error(1)
Result.Error(1).swap();
// ==> Result.Ok(1)
{
/*~*/
Error: function swap() {
return Ok(this.value);
},
/*~*/
Ok: function swap() {
return Error(this.value);
}
}