Re-add state monad - #210
Merged
Merged
Conversation
caioaao
reviewed
Feb 2, 2018
| (return y))) | ||
| (def initial-state 1) | ||
| (run-state computation initial-state) | ||
| This should be return something to: #<Pair [1 2]>" |
Contributor
There was a problem hiding this comment.
This should return #<Pair [1 2]>
|
is there any way to upvote this? :) |
Collaborator
Author
|
@niwinz Can we merge this? |
sovelten
force-pushed
the
add-state-monad
branch
from
August 29, 2018 21:38
98cdc50 to
480e525
Compare
Contributor
|
this makes me a bit happy - i was using a private version of the old state-monad i'm also using a private version of the what dyall think of reviving the monad transformer stuff too ? |
Collaborator
Author
|
I never found myself in need of using a monad transformer in Clojure, but I don't see why not revive them. |
|
Can we also update the docs to reflect the new monad? Keep up the good work guys! |
sovelten
pushed a commit
to nubank/cats
that referenced
this pull request
Sep 3, 2018
* Change either monad to record
This allows us to use `clojure.spec` with it :)
```clojure
(s/def :un/right int?)
(s/def :un/left string?)
(s/def :either/spec (s/and either/either?
(s/or :right (s/and either/right? (s/keys :req-un [:un/right]))
:left (s/and either/left? (s/keys :req-un [:un/left])))))
```
I'm still not sure how to make it compatible with generators.
* Turn maybe monad into record
* Turn identity into record
* Exception monad type -> record
* Add identity predicate
* Fix issue of dynamic context overriding default context
* Fix comment indentation
* convert maybe/maybe from func to macro to delay arg eval
* cond -> boolean logic refactor
* Add test info to README
* require maybe macro in cljs; only check assertion error in clj
* Test delayed maybe/maybe arg evaluation in cljs
* change test case to pass valid argument type to 'maybe' function
* test to ensure `default` isn't evaluated when unused in `maybe`
* Fix typo on 'Pattern matching' link to cats.match
* Update dependencies.
* Set version to 2.2.0
* Rename Success/Failure value names to better match Left/Right and Just
* Re-add state monad (funcool#210)
* re-add state monad
hojacartaft
added a commit
to hojacartaft/cats
that referenced
this pull request
Aug 25, 2024
When the state monad was re-added in funcool/cats#210, `*-state` functions were renamed to `*` (funcool/cats#210 (comment)) but `run-state` was not updated to `run` in a few docstrings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR readds the state monad implementation from the previous version of cats (https://github.com/funcool/cats/blob/1.2.1/src/cats/labs/state.cljc) with some changes. The changes were:
*-stateto*to avoid useless repetitionwrap-fn)