Skip to content

Commit

Permalink
Merge pull request #63 from nubank/dc/make-return-primitive-construct…
Browse files Browse the repository at this point in the history
…able

make `return` constructable/def'able
  • Loading branch information
dchelimsky authored Jan 20, 2020
2 parents 851620d + 205c824 commit 210798c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Changelog

## [DEV]
## [2.1.5]

- Make `state-flow.state/return` constructable/def'able outside monadic context.

## [2.1.4]

Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject nubank/state-flow "2.1.4"
(defproject nubank/state-flow "2.1.5"
:description "Postman-like integration testing with composable flows"
:url "https://github.com/nubank/state-flow"
:license {:name "MIT"}
Expand Down
2 changes: 1 addition & 1 deletion src/state_flow/state.clj
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
(defn return
"Returns the equivalent of (fn [state] [v, state])"
[v]
(m/return v))
(m/return error-context v))

(defn ^:deprecated swap
"DEPRECATED: use modify"
Expand Down
6 changes: 6 additions & 0 deletions test/state_flow/state_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
[state-flow.state :as state]))

(deftest state
(testing "primitives are constructable outside monad context"
(state/get)
(state/gets inc)
(state/modify inc)
(state/return 37)
(state/put {:count 0}))
(let [increment-state (m/mlet [x (state/get)
_ (state/put (inc x))]
(m/return x))
Expand Down

0 comments on commit 210798c

Please sign in to comment.