From dfad3a25c306b06873a436d4b8ce7d764bf29005 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 16 Feb 2016 03:55:52 -0600 Subject: [PATCH 1/4] Update #'cats.core.monad.maybe/just Remove nullary clause, since that doesn't make much sense anyway, and add a precondition to the remaining unary clause to ensure v is non-nil. Update the docsctring accordingly. --- src/cats/monad/maybe.cljc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/cats/monad/maybe.cljc b/src/cats/monad/maybe.cljc index 7c7efd3..ce53a7b 100644 --- a/src/cats/monad/maybe.cljc +++ b/src/cats/monad/maybe.cljc @@ -111,12 +111,10 @@ false)) (defn just - "A Just type constructor. - - Without arguments it returns a Just instance - with nil as wrapped value." - ([] (Just. nil)) - ([v] (Just. v))) + "A Just type constructor." + [v] + {:pre [(some? v)]} + (Just. v)) (defn nothing "A Nothing type constructor." From 3c57373e052112d9c8a49e8c2b768c4544161152 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 16 Feb 2016 04:22:20 -0600 Subject: [PATCH 2/4] Update cats.monad.maybe In -mreturn, if v is nil, return #, otherwise #. --- src/cats/monad/maybe.cljc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cats/monad/maybe.cljc b/src/cats/monad/maybe.cljc index ce53a7b..c9650ce 100644 --- a/src/cats/monad/maybe.cljc +++ b/src/cats/monad/maybe.cljc @@ -202,7 +202,9 @@ p/Monad (-mreturn [_ v] - (just v)) + (if (nil? v) + (nothing) + (just v))) (-mbind [_ mv f] (if (nothing? mv) mv From 1eed32347668e1a4cedb9e476a945dcda49f1960 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 16 Feb 2016 04:23:11 -0600 Subject: [PATCH 3/4] Update #'cats.core/guard (return b) instead of (return nil) This is mostly so the maybe tests pass and could be very misguided. --- src/cats/core.cljc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cats/core.cljc b/src/cats/core.cljc index 7d4f7de..0b20ea3 100644 --- a/src/cats/core.cljc +++ b/src/cats/core.cljc @@ -110,7 +110,7 @@ (defn guard [b] (if b - (return nil) + (return b) (mzero))) (defn join From 0a2b4981a9c9444e0e3ad4a598ba9c06fb9cd31e Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 16 Feb 2016 04:53:00 -0600 Subject: [PATCH 4/4] Update #'cats.core/guard (return true) per @dialelo's suggestion. https://github.com/funcool/cats/pull/149#issuecomment-184622726 --- src/cats/core.cljc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cats/core.cljc b/src/cats/core.cljc index 0b20ea3..c05f8d1 100644 --- a/src/cats/core.cljc +++ b/src/cats/core.cljc @@ -110,7 +110,7 @@ (defn guard [b] (if b - (return b) + (return true) (mzero))) (defn join