prototype

The container for instance methods for Error variants of the Result structure.

This feature is experimental!

This API is still experimental, so it may change or be removed in future versions. You should not rely on it for production applications.

Documentation

The container for instance methods for Error variants of the Result structure.

Properties

Combining

concat()

Combines two Results such that if they're both successful (Ok) their values are concatenated. Otherwise returns the failure.

Comparing and testing

equals(value)

Performs a deep-comparison of two Result values for equality. See adt/union/derivations/equality for details.

Experimental
hasInstance(value)

Tests if an arbitrary value is a Result instance.

ExperimentalInherited
get isError

True if the value is a Error instance.

Deprecated

Constructing

of(value)

Constructs a Result holding an Ok value.

ExperimentalInherited

Converting to other types

toMaybe()

Transforms a Result into a Maybe. Error values are lost in the process.

ExperimentalInherited
toValidation()

Transforms a Result into a Validation.

ExperimentalInherited

Data fields

get value

The value contained in an Error instance of the Result structure.

Abstract

Debugging

inspect: toString()

A textual representation for Result instances.

Experimental
toString()

A textual representation for Result instances.

Experimental

Extracting values

get()

This method has been renamed to unsafeGet().

DeprecatedInherited
getOrElse()

Extracts the value of a Result structure, if it exists (i.e.: is an Ok), otherwise returns the provided default value.

Experimental
merge()

Returns the value inside of the Result structure, regardless of its state.

ExperimentalInherited
unsafeGet()

Extracts the value from a Result structure.

Experimental

Fantasy Land

ap(that)

Part of the Applicative instance for Fantasy Land 1.x. See the apply method for details.

fantasy-land/ap(that)

Part of the Applicative instance for Fantasy Land 2.x+. See the apply method for details.

fantasy-land/bimap(f, g)

Part of the Bifunctor instance for Fantasy Land 2.x+. See the bimap method for details.

fantasy-land/chain(transformation)

Part of the Monad instance for Fantasy Land 2.x+. See the chain method for details.

fantasy-land/concat(that)

Part of the Semigroup instance for Fantasy Land 2.x+. See the concat method for details.

fantasy-land/equals(that)

Part of the Setoid instance for Fantasy Land 2.x+. See the equals method for details.

fantasy-land/map(transformation)

Part of the Functor instance for Fantasy Land 2.x+. See the map method for details.

fantasy-land/of(value)

Part of the Applicative instance for Fantasy Land 2.x+. See the of method for details.

Meta-programming

derive(...derivations)

Allows a function to provide functionality to variants in an union.

ExperimentalInherited

Pattern matching

fold()

Applies a function to each case of a Result.

Experimental
matchWith(pattern)

Chooses and executes a function for each variant in the Result structure.

Experimental

Recovering from errors

orElse()

Allows recovering from Error values with a handler function.

Experimental
swap()

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.

Experimental

Serialising

fromJSON(value, parsers = { [typeName]: adt }, keysIndicateType = false)

Parses a JavaScript object previously serialised as aResult.toJSON() into a proper Result structure.

ExperimentalInherited
toJSON()

Converts a Result value to a JavaScript object that may be stored as a JSON value.

Experimental

Special values

get constructor

The constructor for this variant.

variants

The variants in the Result structure.

ExperimentalInherited

Transforming

apply()

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.

Experimental
bimap()

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.

Experimental
chain()

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.

Experimental
filter()

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.

Experimental
map()

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.

Experimental
mapError()

Transforms the value inside an Error without changing the context of the computation.

Experimental

Variants

Error(value)

Constructs a Result whose value represents a failure.

ExperimentalInherited
Ok(value)

Constructs a Result whose value represents a success.

ExperimentalInherited

Source Code

Defined in source/adt/union/union.js at line 95, column 25
InternalConstructor.prototype
Stability
experimental
Licence
MIT
Module
folktale/adt/union/union
Authors
Copyright
(c) 2013-2017 Quildreen Motta, and CONTRIBUTORS
Authors
  • Quildreen Motta
Maintainers
  • Quildreen Motta <queen@robotlolita.me> (http://robotlolita.me/)