toMaybe

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

This feature is experimental!

This API is still experimental, so it may change or be removed in future versions. You should not rely on it for production applications.

Signature

toMaybe()
forall a, b: (Result a b).() => Maybe b

Documentation

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

Example:

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

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

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

Properties

Source Code

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