Comments (4)
Yeah, that's fine by me.
from galaxus.functional.
@phkiener This will not work because using T?
requires T
to be
- either a value type
- or a not nullable reference type
We usually just use T
without constraints (Option<T>
or Either<A, B>
). The problem is that the compiler needs to know wether 1. or 2. is the case. And we cannot say which is the case because we always need both at the same time.
We can get around this issue by using the !
operator. But that negates the benefit almost completely. I think the overhead of doing this outweights the benefits.
See also:
- https://stackoverflow.com/questions/58229782/receiving-error-about-nullable-type-parameter-even-when-parameter-has-notnull-co
- https://stackoverflow.com/a/54594285/2173516
from galaxus.functional.
Damn, you're right. And the hole goes all the way down - even if we were to just annotate the entries to the abstractions (ToOption() and the likes), it would just spiral down like async does.
Still a shame though, they're a nice feature and something that could help when integrating. But it won't be worth it if we basically have to rework large parts... better accept it and know where stuff is null than introduce a bazillion breaking changes.
from galaxus.functional.
I feel like Microsoft should iterate on the design of nullable refs. Maybe we will see an improved version in a future C# version which is more flexible that the current design. One where we can use value and reference types interchangeably.
Shall we close the issue as won't do?
from galaxus.functional.
Related Issues (20)
- Enforce (?) code style
- Implementation of FirstOrNone, LastOrNone and SingleOrNone are not Lazy. HOT 3
- Consider an Option.Some constructor relying on type inference. HOT 3
- Build produces a lot of documentation warnings HOT 1
- .IsA / .IsB / .SelectA / .SelectB for Either<A, B>
- Add async support for Either2.Match and Either3.Match HOT 1
- Option-Type value getter for dictionaries
- Option to Either HOT 1
- Introduce Tap HOT 2
- Naming of AttemptToUnwrapNoneWhenOptionContainedSomeException HOT 3
- Extract async-extensions into their own "module" HOT 2
- Allow pattern-matching on Option, Result and maybe even Either
- Add NUnit Testing Extensions HOT 1
- Introduce MatchAsync method for Option HOT 3
- Polish package packing process
- Add async Option.MapOr and Or
- Add Option.MapOrElse HOT 1
- Add Result.FlatMap HOT 1
- Add a way to convert an Option<T> to an Either<A, T> HOT 2
- ConfigureAwait(false) for async extensions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from galaxus.functional.