fromMaybe

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

Signature

fromMaybe(aMaybe, failureValue)
forall a, b: (Maybe b, a) => Result a b

Documentation

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

Example:

const Result = require('folktale/result');
const Maybe = require('folktale/maybe');

Result.fromMaybe(Maybe.Just(1), 'error');
// ==> Result.Ok(1)

Result.fromMaybe(Maybe.Nothing(), 'error');
// ==> Result.Error('error')

Properties

Source Code

Defined in source/result/index.js at line 18, column 17
fromMaybe(aMaybe, failureValue) {
    return require('folktale/conversions/maybe-to-result')(aMaybe, failureValue);
  }
Licence
MIT
Module
folktale/result
Authors
Copyright
(c) 2013-2017 Quildreen Motta, and CONTRIBUTORS
Authors
  • Quildreen Motta
Maintainers
  • Quildreen Motta <queen@robotlolita.me> (http://robotlolita.me/)