From c0870ebef662517b84218731ea9a1ed2b9879221 Mon Sep 17 00:00:00 2001 From: Eugene Sharygin Date: Mon, 18 Feb 2019 20:54:54 +0300 Subject: [PATCH] Make nothing :: Maybe a, remove extra parameter `nothing` is only used in one place, and as a function it was called incorrectly before: `nothing()` instead of `nothing(undefined)`. This commit fixes that by removing the extra layer of function wrapping entirely, and making `nothing` a constant of type `Maybe a`. This is to avoid the more verbose alternative - adding the `undefined` argument. --- appendix_a.md | 4 ++-- exercises/ch11/solution_a.js | 2 +- exercises/support.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/appendix_a.md b/appendix_a.md index 3cd3bfd7..d8729534 100644 --- a/appendix_a.md +++ b/appendix_a.md @@ -141,8 +141,8 @@ const maybe = curry((v, f, m) => { ## nothing ```js -// nothing :: () -> Maybe a -const nothing = () => Maybe.of(null); +// nothing :: Maybe a +const nothing = Maybe.of(null); ``` diff --git a/exercises/ch11/solution_a.js b/exercises/ch11/solution_a.js index ff5501db..0ea3424c 100644 --- a/exercises/ch11/solution_a.js +++ b/exercises/ch11/solution_a.js @@ -1 +1 @@ -const eitherToMaybe = either(_ => nothing(), Maybe.of); +const eitherToMaybe = either(always(nothing), Maybe.of); diff --git a/exercises/support.js b/exercises/support.js index 4dc02f83..56ebe432 100644 --- a/exercises/support.js +++ b/exercises/support.js @@ -579,7 +579,7 @@ const maybe = curry(function maybe(v, f, m) { return f(m.$value); }); -const nothing = function nothing() { return Maybe.of(null); }; +const nothing = Maybe.of(null); const reject = function reject(x) { return Task.rejected(x); };