Skip to content

Commit 533c5a7

Browse files
authored
add gets context (#235)
* add gets context
1 parent aa30e0c commit 533c5a7

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog #
22

3+
## Version 2.3.4
4+
5+
Date: 2020-02-11
6+
7+
- gets can receive monad context as argument
8+
39
## Version 2.3.3
410

511
Date: 2019-10-02

project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject funcool/cats "2.3.3"
1+
(defproject funcool/cats "2.3.4"
22
:description "Category Theory abstractions for Clojure"
33
:url "https://github.com/funcool/cats"
44
:license {:name "BSD (2 Clause)"

src/cats/monad/state.cljc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,11 @@
167167
(defn gets
168168
"State monad that returns the result of applying
169169
a function to a state"
170-
[projfn]
171-
(m/mlet [s (get)]
172-
(m/return (projfn s))))
170+
([projfn context]
171+
(m/mlet [s (get context)]
172+
(m/return (projfn s))))
173+
([projfn]
174+
(gets projfn (get-context))))
173175

174176
(defn wrap-fn
175177
"Wraps a (possibly side-effecting) function to a state monad"

0 commit comments

Comments
 (0)