You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When writing LINQ queries one often wants to evaluate the result immediately (especially in an multithreaded environments) rather than lazily, so quite often one uses a ToList() or a ToArray():
(fromiinnumberswherei<0selecti*2).ToArray();
Since this requires the use of brackets around the query, the readability advantages of LINQ are reduced and often people drop LINQ and instead use chained extension methods:
numbers.Where(i =>i<0).Select(i =>i*2).ToArray();
The same happens with all methods that exit the monad, e.g. First/Last/Single, Any/All/Contains, Aggregate, Average/Min/Max/Sum, Count, etc.
So wouldn’t it be nice to support an extra clause in LINQ that would let one apply any of these methods to the query?
fromiinnumberswherei<0selecti*2
eval ToArray();
I am using the eval keyword here as it does actually result in the evaluation of the query.
When writing LINQ queries one often wants to evaluate the result immediately (especially in an multithreaded environments) rather than lazily, so quite often one uses a ToList() or a ToArray():
Since this requires the use of brackets around the query, the readability advantages of LINQ are reduced and often people drop LINQ and instead use chained extension methods:
The same happens with all methods that exit the monad, e.g. First/Last/Single, Any/All/Contains, Aggregate, Average/Min/Max/Sum, Count, etc.
So wouldn’t it be nice to support an extra clause in LINQ that would let one apply any of these methods to the query?
I am using the eval keyword here as it does actually result in the evaluation of the query.
Similarly for queries on Option/Maybe
More details and a demo are available here
The text was updated successfully, but these errors were encountered: