prototype

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

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.

Inherited
get isError

True if the value is a Error instance.

Deprecated

Constructing

of(value)

Constructs a Result holding an Ok value.

Inherited

Converting to other types

toMaybe()

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

Inherited
toValidation()

Transforms a Result into a Validation.

Inherited

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.

merge()

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

Inherited
unsafeGet()

Extracts the value from a Result structure.

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.

matchWith(pattern)

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

Recovering from errors

orElse()

Allows recovering from Error values with a handler function.

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.

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.

Inherited

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.

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.

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.

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.

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.

mapError()

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

Variants

Error(value)

Constructs a Result whose value represents a failure.

Inherited
Ok(value)

Constructs a Result whose value represents a success.

Inherited

Source Code

Defined in source/adt/union/union.js at line 128, column 25
InternalConstructor.prototype
Stability
stable
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/)