fromResult

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

Signature

fromResult(aResult)
forall a, b: (Result a b) => Maybe b

Documentation

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

Note that Error values are discarded, since Nothing can't hold a value.

Example:

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

Maybe.fromResult(Result.Ok(1));
// ==> Maybe.Just(1)

Maybe.fromResult(Result.Error(1));
// ==> Maybe.Nothing()

Properties

Source Code

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