3 ms·
> Basically, the monadic type use of these is an effect of the language doing that, not the other way. In e.g. C# where I use option types extensively I'm yet t
by catnaroek 9y ago
> Basically, the monadic type use of these is an effect of the language doing that, not the other way. In e.g. C# where I use option types extensively I'm yet to see a wrapped one.
And C# pays dearly for it. Why doesn't C# have anything like C++'s <algorithm>, or Rust's composable iterators, or Haskell's plethora of composable abstractions (foldables, traversables, lenses, etc.)?
> In C# there is a feature in which (...) but to be honest this to me feels mostly quirky because it doesn't extend to much else in the language.
Agreed. Hardcoded special cases are always a bad idea.
---
Sorry, HN won't allow me to make a new post because “I'm submitting too fast”, so here goes my reply:
C++ has a finer-grained hierarchy of iterator concepts:
(0) InputIterators correspond to C# IEnumerators.
(1) OutputIterators allow you to write to the sequence's current element.
(2) ForwardIterators allow you to dereference the current element arbitrarily many times before moving on to the next.
(3) BidirectionalIterators allow you to move both forward and backwards in the sequence of elements.
(4) RandomAccessIterators allow you to skip arbitrarily many positions in the sequence of elements in constant time.
And there are algorithms defined in terms of these refined iterator concepts.
- alkonaut 9y ago> Why doesn't C# have anything like C++'s <algorithm>, or Rust's composable iterators, or Haskell's plethora of composable abstractions (foldables, traversables, lenses, etc.)? I'm not very familiar with the details of Rust iterators yet, but there isn't much I'm missing from Linq at least yet (apart from the cost control available in Rust and C++ that it's pretty natural is omitted from C# where it's natural that operations such as iteration can heap allocate). What is the difference between <algorithms> and the similar Linq (or rather the enumerable extensions enabling linq)?