Comments (2)
You are right! Thanks for report it.
from cats.
Assume the following definition of mf
for all Clojure examples below.
(def mf #(e/right (* % 2)))
Given the following behaviour in Haskell:
Prelude> import Control.Monad (mapM)
Prelude Control.Monad> mapM (Right . (* 2)) [1..4]
Right [2,4,6,8]
Prelude Control.Monad> mapM (Right . (* 2)) []
Right []
it seems to me that:
(m/mapseq mf [])
should return
#<Right [()]>
but without a solution for #69, I'm not sure how to infer the context of mf
.
We could however, redefine sequence
as follows:
(defn sequence [mvs]
(if (empty? mvs)
(return (ctx/get-current) ())
(let [ctx (ctx/get-current (first mvs))]
(ctx/with-context ctx
(reduce (fn [mvs mv]
(mlet [v mv
vs mvs]
(return (cons v vs))))
(return ())
(reverse mvs))))))
and allow users to write code like this:
(ctx/with-context e/context
(m/mapseq mf []))
which would then produce the desired
#<Right [()]>
Thoughts?
from cats.
Related Issues (20)
- Why is the implementation of rights not extracting the values from right? HOT 4
- No such namespace: promesa.impl.proto (required from cats.labs.promise) HOT 1
- haskell's sequence HOT 2
- foldl Documentation Example fail HOT 1
- lift-a produces an exception when n is (inc 1) but not when n is 2 HOT 1
- maybe/nothing doesn't have to be a function
- Please release fmap fix HOT 10
- doc for fapply - wrap in the same context as af?
- Documentation is broken HOT 3
- Reflections in the state monad HOT 3
- 2.3.0 not available on clojars HOT 6
- Missing tag 2.3.1 HOT 1
- Can't build the 2.3.1: failed compiling file:src/cats/monad/state.cljc HOT 1
- Naming conventions
- Add a jupyter notebook with the documentation. HOT 2
- cats.labs.promise support for promesa 2.x
- Error printing return value of try monad in REPL HOT 3
- Apparent inconsistent behaviour of alet compared to mlet HOT 2
- Code examples in the documentation don't return what's expected
- Cats does not work with new versions of Promesa
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cats.