Our great sponsors
-
vonage-dotnet-sdk
Vonage REST API client for .NET, written in C#. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
Previously, we built an Optional and showed an existing set based on Language-Ext, but various libraries also offer Monad implementations. In the case of our SDK, we deliberately avoided relying on external libraries like Language-Ext. Indeed, Monads are a part of the SDK's public API, and relying on an external library would introduce a dependency over which we would have limited control.
You probably noticed that .SetName() returns a Either. You may have come across Unit in libraries like MediatR or Language-Ext. It's a simple construct representing a type with only one possible value. We use it as a placeholder for operations that do not return a value but may return another state. In our example, .SetName() is a Command that does not return a value but may fail. Therefore, the monad Either carries two possible states: Right (without value) or Left (with an Error).
You probably noticed that .SetName() returns a Either. You may have come across Unit in libraries like MediatR or Language-Ext. It's a simple construct representing a type with only one possible value. We use it as a placeholder for operations that do not return a value but may return another state. In our example, .SetName() is a Command that does not return a value but may fail. Therefore, the monad Either carries two possible states: Right (without value) or Left (with an Error).
Related posts
- Result pattern: language-ext vs FunctionalExtensions?
- Exception handling between controller and service
- Three words.,, => C# Functional Programming is awesome!!! Do you seasoned developers have any war-stories or nightmare stories regarding Functional Programming?
- Just “Discovered” Linq. Now Whole Program is Full of Linq.
- What's a pattern similar to Rust's Option<Option<T>>?