# Module: data.either¶

Stability: 3 - Stable https://github.com/folktale/data.either/issues 1.2.0 https://github.com/folktale/data.either Portable data.either

A structure for disjunctions (e.g.: computations that may fail).

The Either(α, β) structure represents the logical disjunction between α and β. In other words, Either may contain either a value of type α, or a value of type β, at any given time, and it’s possible to know which kind of value is contained in it.

This particular implementation is biased towards right values (β), thus common projections (e.g.: for the monadic instance) will take the right value over the left one.

Require the data.either package, after installing it:

var Either = require('data.either')


This gives you back an data.either.Either object.

## Why?¶

A common use of this structure is to represent computations that may fail when you want to provide additional information on the failure. This can force failures and their handling to be explicit, avoiding the problems associated with throwing exceptions: non locality, abnormal exits, unintended stack unwinding, etc.

class data.either.Either
type Either(α, β) = Left(α) | Right(β)

Represents the logical disjunction between α and β.