Stack Overflow when calling BindT on Enumerable of Either
See original GitHub issueThis small test demonstrates the problem:
[Test]
public void Enumerable_BindT_StackOverflow()
{
IEnumerable<Either<bool, string>> input = Enumerable.Repeat("1", 50000).Select(Prelude.Right<bool, string>);
IEnumerable<Either<bool, int>> output = input.BindT(s => TryParseInt(s));
Either<bool, int>[] arr = output.ToArray(); // This will fail here with a Stack Overflow (deferred exec)
/*** Local Func ***/
Either<bool, int> TryParseInt(string s)
{
if (int.TryParse(s, out int i))
return i;
else
return false;
}
}
Appears the stack overflows due to chained calls to MEnumerable.MoveNext()
Note: I was able to work around it by only manipulating the Enumerable using LINQ Select
calls, then calling Bind
on each individual ‘either’ value. The problem seems to be how BindT
operates on the enumerable.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Stack overflow error after using Sequence to get from ...
I have some code sorta like this: var someData = Enumerable . ... Stack Overflow when calling BindT on Enumerable of Either #569....
Read more >c# - How to bind on multiple Either<,>?
This will call SelectMany on the monadic type which is Bind (see documentation of LanguageExt). You get a right value if every function ......
Read more >c# - Method returning IEnumerable<T> should ToList() or not
To answer you question, I think that yes you should call ToList before returning the enumeration mainly because your ...
Read more >Thirteen ways of looking at a turtle
Calling the turtle object. The client code instantiates the turtle and talks to it directly: /// Function to log a message ...
Read more >Language Ext Versions
repeatM was causing a stack-overflow on usage, this is now fixed. Example usage: public static Effect<Runtime, Unit> effect => Producer.repeatM(Time<Runtime>.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have committed a fix for this that will be in the next release.
Sorry - I forgot to include the environment details…
Yes, v3.1.15 passes the test on .NET Core 2.1 as well. Just appears to be a problem on .NET Framework (4.6.1)