FunctionalDdd.RailwayOrientedProgramming 1.1.1

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package FunctionalDdd.RailwayOrientedProgramming --version 1.1.1
NuGet\Install-Package FunctionalDdd.RailwayOrientedProgramming -Version 1.1.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FunctionalDdd.RailwayOrientedProgramming" Version="1.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FunctionalDdd.RailwayOrientedProgramming --version 1.1.1
#r "nuget: FunctionalDdd.RailwayOrientedProgramming, 1.1.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FunctionalDdd.RailwayOrientedProgramming as a Cake Addin
#addin nuget:?package=FunctionalDdd.RailwayOrientedProgramming&version=1.1.1

// Install FunctionalDdd.RailwayOrientedProgramming as a Cake Tool
#tool nuget:?package=FunctionalDdd.RailwayOrientedProgramming&version=1.1.1

Railway Oriented Programming

Structs

Result

Result object holds the result of an operation or Error It is defined as

public readonly struct Result<TValue>
{
    public TValue Value => IsSuccess ? _value! : throw new InvalidOperationException;
    public Error Error => IsFailure ? _error! : throw new InvalidOperationException;

    public bool IsSuccess => !IsFailure;
    public bool IsFailure { get; }

    public static implicit operator Result<TValue>(TValue value) => Result.Success(value);

    public static implicit operator Result<TValue>(Error error) => Result.Failure<TValue>(error);
 }

Maybe

Maybe object holds a value or nothing. It is defined as

 public readonly struct Maybe<T> :
    IEquatable<T>,
    IEquatable<Maybe<T>>
    where T : notnull
{
   public T Value;
   public bool HasValue;
   public bool HasNoValue;
}

Functions

Bind

Bind calls the given function if the result is in success state and return the new result.

Tap

Tap calls the given function if the result is in success state and returns the same result.

Compensate

Compensate for failed result by calling the given function.

Ensure

Ensure calls the given function if the result is in success state. If the function returns false, the attached error is returned.

Map

Map calls the given function if the result is in success state. The return value is wrapped in Result as success.

Combine

Combine combines multiple Result objects. It will return a Result with all the errors if any of the Result objects have failed. If all the errors are of type ValidationError, then it will return a ValidationError with all the errors. Otherwise it will return an AggregatedError

ParallelAsync

Parallel runs multiple tasks in parallel and returns multiple tasks. BindAsync will await all the task and call the given function.

Finally

Finally unwraps the Result and returns the success value or the error.

Maybe

Maybe states if it contains a value or not. It has the following methods:

  • HasValue - returns true if it has a value.
  • HasNoValue - returns true if it does not have a value.
  • Value - returns the value if it has a value. Otherwise InvalidOperationException
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on FunctionalDdd.RailwayOrientedProgramming:

Package Downloads
FunctionalDdd.FluentValidation

Convert fluent validation errors to FunctionalDdd Validation errors.

FunctionalDdd.Asp

These extension methods are used to convert the ROP Result object to ActionResult. If the Result is in a failed state, it returns the corresponding HTTP error code.

FunctionalDdd.CommonValueObjects

To avoid passing around strings, it is recommended to use RequiredString to obtain strongly typed properties. The source code generator will automate the implementation process.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0-alpha.38 33 4/24/2024
2.0.0-alpha.33 47 4/17/2024
2.0.0-alpha.26 58 4/9/2024
2.0.0-alpha.21 67 4/1/2024
2.0.0-alpha.19 51 3/5/2024
2.0.0-alpha.18 50 2/28/2024
2.0.0-alpha.17 59 2/26/2024
2.0.0-alpha.15 68 1/30/2024
2.0.0-alpha.8 50 1/27/2024
2.0.0-alpha.6 89 1/5/2024
1.1.1 934 11/15/2023
1.1.0-alpha.32 95 11/2/2023
1.1.0-alpha.30 193 11/1/2023
1.1.0-alpha.28 77 10/28/2023
1.1.0-alpha.27 74 10/28/2023
1.1.0-alpha.24 62 10/20/2023
1.1.0-alpha.23 69 10/13/2023
1.1.0-alpha.21 82 10/1/2023
1.1.0-alpha.20 63 9/30/2023
1.1.0-alpha.19 76 9/30/2023
1.1.0-alpha.18 82 9/29/2023
1.1.0-alpha.17 59 9/22/2023
1.1.0-alpha.13 54 9/16/2023
1.1.0-alpha.4 123 6/9/2023
1.1.0-alpha.3 73 6/8/2023
1.0.1 1,124 5/12/2023
0.1.0-alpha.40 101 4/6/2023
0.1.0-alpha.39 96 4/3/2023
0.1.0-alpha.38 125 4/2/2023
0.1.0-alpha.37 105 3/31/2023
0.1.0-alpha.35 102 3/29/2023
0.1.0-alpha.34 91 3/28/2023
0.1.0-alpha.32 123 3/18/2023
0.1.0-alpha.30 110 3/11/2023
0.1.0-alpha.27 106 3/7/2023
0.1.0-alpha.24 109 2/15/2023
0.1.0-alpha.22 103 2/15/2023
0.1.0-alpha.20 111 2/13/2023
0.0.1-alpha.14 131 1/4/2023
0.0.1-alpha.4 114 12/30/2022