Skip to content

Commit

Permalink
Fix for Issue 533 - Stack overflow error after using Sequence to get …
Browse files Browse the repository at this point in the history
…from IEnumerable<Option<T>> to Option<IEnumerable<T>>

#533
  • Loading branch information
louthy committed Dec 7, 2018
1 parent 5bf2bae commit c808fb7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
7 changes: 2 additions & 5 deletions LanguageExt.Core/ClassInstances/Monad/MEnumerable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,8 @@ public Func<Unit, S> FoldBack<S>(IEnumerable<A> fa, S state, Func<S, A, S> f) =>
fa.FoldBack(state, f);

[Pure]
public IEnumerable<A> Plus(IEnumerable<A> ma, IEnumerable<A> mb)
{
foreach (var a in ma) yield return a;
foreach (var b in mb) yield return b;
}
public IEnumerable<A> Plus(IEnumerable<A> ma, IEnumerable<A> mb) =>
Enumerable.Concat(ma, mb);

[Pure]
public IEnumerable<A> Zero() =>
Expand Down
19 changes: 19 additions & 0 deletions LanguageExt.Tests/IssuesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -481,4 +481,23 @@ public static async Task<Option<int>> Calculate(int x, int y, int z)
// .IfLeft(0);
//}
}

public class Issue533
{
[Fact]
public void Test()
{

var someData = Enumerable
.Range(0, 30000)
.Select(_ => Guid.NewGuid().ToString())
.ToArray();

var result = someData
.Select(Some)
.Sequence()
.Map(x => x.ToArray());
}

}
}

0 comments on commit c808fb7

Please sign in to comment.