Constructs a Result whose value represents a failure.
This API is still experimental, so it may change or be removed in future versions. You should not rely on it for production applications.
Constructs a Result whose value represents a failure.
See the documentation for the Result structure to understand how to use this.
Tests if an arbitrary value is a Error case of a Result instance.
A textual representation of the Error variant.
A textual representation of the Error variant.
The constructor for this variant.
The container for instance methods for Error variants of the Result structure.
The tag for this variant, unique among the Result variants.
The type for this variant, unique among Folktale data structures (and ideally unique among all unions in your application, as its used for type checking).
Combines two Results such that if they're both successful (Ok
) their values are
concatenated. Otherwise returns the failure.
Performs a deep-comparison of two Result values for equality. See adt/union/derivations/equality
for details.
Tests if an arbitrary value is a Result instance.
True if the value is a Error
instance.
Constructs a Result holding an Ok value.
Transforms a Result into a Maybe. Error values are lost in the process.
Transforms a Result into a Validation.
The value contained in an Error instance of the Result structure.
A textual representation for Result instances.
A textual representation for Result instances.
This method has been renamed to unsafeGet()
.
Extracts the value of a Result
structure, if it exists (i.e.: is an Ok
),
otherwise returns the provided default value.
Returns the value inside of the Result structure, regardless of its state.
Extracts the value from a Result
structure.
Part of the Applicative instance for Fantasy Land 1.x. See the apply
method for details.
Part of the Applicative instance for Fantasy Land 2.x+. See the apply
method for details.
Part of the Bifunctor instance for Fantasy Land 2.x+. See the bimap
method for details.
Part of the Monad instance for Fantasy Land 2.x+. See the chain
method for details.
Part of the Semigroup instance for Fantasy Land 2.x+. See the concat
method for details.
Part of the Setoid instance for Fantasy Land 2.x+. See the equals
method for details.
Part of the Functor instance for Fantasy Land 2.x+. See the map
method for details.
Part of the Applicative instance for Fantasy Land 2.x+. See the of
method for details.
Allows a function to provide functionality to variants in an union.
Applies a function to each case of a Result.
Chooses and executes a function for each variant in the Result structure.
Parses a JavaScript object previously serialised as aResult.toJSON()
into a proper Result structure.
Converts a Result value to a JavaScript object that may be stored as a JSON value.
The constructor for this variant.
The variants in the Result structure.
Applies the function contained in one Result to the value in another Result.
Application only occurs if both Results are Ok
, otherwise keeps the first
Error
.
Transforms each side of a Result with a function, without changing the context of the computation. That is, Errors will still be Errors, Oks will still be Oks.
Transforms the value and context of a Result computation with an unary function.
As with .map()
, the transformation is only applied if the value is an Ok
,
but the transformation is expected a new Result
value, which then becomes the
result of the method.
If the Result is a Ok, passes its value to the predicate. If the predicate returns true, then the Result is returned unchanged. In every other case, an Error gets returned.
Transforms the value inside of a Result structure with an unary function without
changing the context of the computation. That is, Error
values continue to be
Error
values, and Ok
values continue to be Ok
values.
Transforms the value inside an Error without changing the context of the computation.
Constructs a Result whose value represents a failure.
Constructs a Result whose value represents a success.
Error(value) {
return { value };
}