2 ms·
Right, ‘some type that has a Select(Func<T, S>) method available’ is not a thing you can express in C# generic constraints. But I don’t need a function that do
by jameshart 1y ago
Right, ‘some type that has a Select(Func<T, S>) method available’ is not a thing you can express in C# generic constraints.
But I don’t need a function that does that, the language has syntax for it - I can just do that wherever I need it.
- instig007 1y ago> Right, ‘some type that has a Select(Func<T, S>) method available’ not just Select(Func<T, S>), but a Select(Func<T, S>) that preserves its original contextual instance of Select and doesn't leak into a different instance with Select. > But I don’t need a function that does that you don't need it yet ;)
- moomin 1y agoYes, but you can’t write something that’s generic over “things that support Select” because that’s not expressible via the type system. So you can’t write a function, then get a version that works on lists, then a version that works on tasks, then a version that works on nullables, then get a version that works on parsers. One if the big secrets on monads is that Haskell users don’t spend very much time thinking about them, while people without monads have to think about them all the time.