Permalink
Browse files

(new conversions) adds Nullable→Maybe conversion

  • Loading branch information...
robotlolita committed Oct 16, 2016
1 parent 450cb70 commit 9706ab79e453473e2c29c9d00054d81f09c584f1
Showing with 33 additions and 0 deletions.
  1. +33 −0 src/data/conversions/nullable-to-maybe.js
@@ -0,0 +1,33 @@
//----------------------------------------------------------------------
//
// This source file is part of the Folktale project.
//
// Copyright (C) 2015-2016 Quildreen Motta.
// Licensed under the MIT licence.
//
// See LICENCE for licence information.
// See CONTRIBUTORS for the list of contributors to the project.
//
//----------------------------------------------------------------------
const { Nothing, Just } = require('folktale/data/maybe/core');
/*~
* Converts a nullable value to a maybe.
* ---
* category: Converting from nullables
* stability: experimental
* authors:
* - Quildreen Motta
*
* type: |
* forall a:
* (a or None) => Maybe a
*/
const nullableToMaybe = (a) =>
a != null ? Just(a)
:/*else*/ Nothing();
module.exports = nullableToMaybe;

0 comments on commit 9706ab7

Please sign in to comment.