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.
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);
}
}