Nothing

Constructs a Maybe value that represents a failure (a Nothing).

Signature

Nothing()
forall a: () => Maybe a

Documentation

Constructs a Maybe value that represents a failure (a Nothing).

See the documentation for the Maybe structure to understand how to use this.

Static properties

Comparing and testing

hasInstance(value)

Tests if an arbitrary value is a Nothing case of a Maybe instance.

Debugging

inspect: toString()

A textual representation of the Nothing variant.

Experimental
toString()

A textual representation of the Nothing variant.

Experimental

Special values

get constructor

The constructor function for this variant.

prototype

The container for instance methods for Nothing variants of the Maybe structure.

get tag

The tag for this variant, unique among the Maybe variants.

get type

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

Instance (prototype) properties

Combining

concat()

Combines two maybes such that if they both have values (are a Just) their values are concatenated. Maybe values are expected to be Fantasy Land 1.x semigroups and implement a concat method.

Comparing and testing

equals(value)

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

Experimental
hasInstance(value)

Tests if an arbitrary value is a Maybe instance.

Inherited
get isNothing

True if the value is a Nothing instance.

Deprecated

Constructing

empty()

Constructs a Maybe containing no value (a Nothing).

Inherited
of(value)

Constructs a Maybe value that represents a successful value (a Just).

Inherited

Converting to other types

toResult(fallbackValue)

A convenience method for the folktale/conversions/maybe-to-result module.

ExperimentalInherited
toValidation(fallbackValue)

A convenience method for the folktale/conversions/maybe-to-validation module.

ExperimentalInherited

Debugging

inspect: toString()

A textual representation for Maybe instances.

Experimental
toString()

A textual representation for Maybe instances.

Experimental

Extracting values

get()

This method has been renamed to unsafeGet().

DeprecatedInherited
getOrElse()

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

unsafeGet()

Extracts the value from a Just 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/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/empty()

Part of the Monoid instance for Fantasy Land 2.x+. See the empty 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

cata()

This method has been replaced by matchWith(pattern). cata(morphism) selects and executes a function for each variant of the Maybe structure.

Deprecated
fold()

Applies a function to each variant of the Maybe structure.

matchWith(pattern)

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

Recovering from errors

orElse()

Allows recovering from from failed Maybe values.

Serialising

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

Parses a JavaScript object previously serialised as aMaybe.toJSON() into a proper Maybe structure.

ExperimentalInherited
toJSON()

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

Experimental

Special values

get constructor

The constructor function for this variant.

variants

The variants in the Maybe structure.

Inherited

Transforming

apply()

Transforms a Maybe value using a function contained in another Maybe. As with .map(), the Maybe values are expected to be Just, and no operation is performed if any of them is a Nothing.

chain()

Transforms an entire Maybe structure with the provided function. As with .map(), the transformation is only applied if the value is a Just, but unlike .map() the transformation is expected to return a new Maybe value.

filter()

If the Maybe is a Just, passes its value to the predicate. If the predicate returns true, then the Maybe is returned unchanged. In every other case, a Nothing gets returned.

Experimental
map()

Transforms the value inside a Maybe structure with an unary function. Only transforms values that are successful (Just), and constructs a new Maybe as a result.

Variants

Just(value)

Constructs a Maybe value that represents a successful value (a Just).

Inherited
Nothing()

Constructs a Maybe value that represents a failure (a Nothing).

Inherited

Source Code

Nothing() {
  }
Stability
stable
Licence
MIT
Module
folktale/maybe/maybe
Authors
Copyright
(c) 2013-2017 Quildreen Motta, and CONTRIBUTORS
Authors
  • Quildreen Motta
Maintainers
  • Quildreen Motta <queen@robotlolita.me> (http://robotlolita.me/)