Comments (6)
I don't see how that PR can do it, but maybe. The code you are running is here I think:
and that code is just not stack safe.
To make it stack safe, we could need to have a similar tree style approach as the PR you linked.
Or, and I think this is simpler, internal to the unorderedTraverse for Map just call .toList
on the Map, do the traverse there, then call .toMap
. If you are converting toList however, I imagine converting to Vector and using traverseViaChain
then converting to Map will be more efficient?
from cats.
we should definitely add this test though, and while we are at it see if there are other UnorderedTraverse instances that may also have an issue.
from cats.
I think the key takeaway here is that it was stack safe in 2.6.1 and I think this was an unexpected side effect of 2.7.0
from cats.
I think we should do a git bisect to find the issue. There were a lot of changes. I don't see how the code you linked is even in the call graph of this example (it may be, I just don't see how).
Also, the current code is not stack safe which you can clearly see (it builds up a linear depth computation).
It is interesting that the difference seems to be with Tuple2 applicative though, and it works here with Option.
Lastly, I'd note that 500 is pretty low to be causing stack overflows. I wonder if the Option example works with say 10000?
from cats.
Tested it with 10000:
val m: Map[Int, Int] = (1 to 10000).map(x => x -> x).toMap
it constructed the map and Scastie hangs after testing Option monad
from cats.
I don't see how that PR can do it, but maybe. The code you are running is here I think:
and that code is just not stack safe.
To make it stack safe, we could need to have a similar tree style approach as the PR you linked.
Or, and I think this is simpler, internal to the unorderedTraverse for Map just call
.toList
on the Map, do the traverse there, then call.toMap
. If you are converting toList however, I imagine converting to Vector and usingtraverseViaChain
then converting to Map will be more efficient?
I might take a look at it. Writing tests to check for SO should be easy.
from cats.
Related Issues (20)
- add `sizeIs` method like std-lib to `cats.Reducible` and/or NonEmpty collections HOT 1
- Maybe you are looking for `as`? :) HOT 2
- Fix documentation (or design) of Free Monad
- Type-classes for Prepend (Cons) and Append (Snoc) operations HOT 5
- Scala 3: No given instance of type cats.Applicative[[_] =>> Any] was found for parameter F of method apply in class PurePartiallyApplied
- Unusual EqLaws definition HOT 4
- Outdated Link in Docs - Seeking Guidance for Fix HOT 1
- algebra-core/src HOT 1
- Option size method implicitly selected from UnorderedFoldable HOT 2
- IndexedStateT has superfluous parts HOT 4
- .splitWhen
- Difference in the Applicative inferred for Seq[Seq[?]]#sequence between Scala 2 and 3
- Inconsistent behaviour when using Eval as Applicative
- `Tuple1SemigroupalOps` methods have different names from other `TupleNSemigroupalOps` classes HOT 3
- Instances for Currency HOT 7
- EitherT[Option, ?, ?]] can't be used as a bifunctor HOT 5
- trait EuclidianRing should not be a Ring HOT 4
- OutOfMemoryError when IO.uncancelable is used in recursive function HOT 1
- ambiguous implicit resolution of `Show.ContravariantShow[immutable.SortedMap[K, V]]` HOT 1
- Should Monad extend Defer? HOT 11
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.