Kehlet.Functional 1.0.25

dotnet add package Kehlet.Functional --version 1.0.25
                    
NuGet\Install-Package Kehlet.Functional -Version 1.0.25
                    
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="Kehlet.Functional" Version="1.0.25" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Kehlet.Functional" Version="1.0.25" />
                    
Directory.Packages.props
<PackageReference Include="Kehlet.Functional" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Kehlet.Functional --version 1.0.25
                    
#r "nuget: Kehlet.Functional, 1.0.25"
                    
#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.
#:package Kehlet.Functional@1.0.25
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Kehlet.Functional&version=1.0.25
                    
Install as a Cake Addin
#tool nuget:?package=Kehlet.Functional&version=1.0.25
                    
Install as a Cake Tool

Kehlet.Functional

Overview

Kehlet.Functional is a C# project focused on implementing functional programming constructs. This project provides a range of functionalities that are essential for functional programming paradigms in C#.

Examples

Monads

using static Kehlet.Functional.Prelude;

var number1 = ok(42);
var number2 = ok(69);
 
Result<int> result1 = from a in number1
                      from b in number2
                      select a + b;

Result<int> result2 = from a in number1
                      from b in number2
                      let sum = a + b
                      select sum > 50
                          ? ok(sum)
                          : error("Number is too low");
public Result<string> WriteFile(string projectName, string filePath, string content, FileWriteMode mode) =>
    from project in ParseProjectName(projectName)
    from file in ParseFilePath(project, filePath)
    let message = file.Exists ? "existing file" : "new file"
    select mode switch
    {
        FileWriteMode.Append => from result in fileSystem.AppendAllText(file.FullName, content) select $"Appended content to {message}: {file.Name}",
        FileWriteMode.Write => from result in fileSystem.WriteAllText(file.FullName, content) select $"Wrote content to {message}: {file.Name}",
        _ => error($"Unsupported mode: {mode}")
    };

LinqPlus

int factorial = from acc in fold(1)
                from value in (int[]) [1, 2, 3, 4, 5]
                select acc * value
Option<int> first = from n in (int[]) [1, 2, 3, 4]
                    select first(n > 2);
Option<int> last = from n in (int[]) [1, 2, 3, 4]
                   select last();
IEnumerable<int> take3 = from n in (int[]) [1, 2, 3, 4]
                         select take(3);
IEnumerable<int> take = from n in (int[]) [1, 2, 3, 4]
                        select takeWhile(n < 3);
Option<(string, float)> last = from student in students
                               from grade in student.Grades
                               select (student.Name, grade) into studentGrades
                               select reverse() into reversed
                               select first();
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.25 274 2/7/2024
1.0.24 232 1/31/2024
1.0.23 225 1/31/2024
1.0.22 219 1/30/2024
1.0.21 216 1/30/2024
1.0.20 236 1/30/2024
1.0.19 291 1/2/2024
1.0.18 234 1/2/2024
1.0.17 248 1/2/2024
1.0.16 252 1/1/2024
1.0.15 264 1/1/2024
1.0.14 250 12/30/2023
1.0.13 256 12/30/2023
1.0.12 250 12/29/2023
1.0.11 247 12/29/2023
1.0.10 232 12/29/2023
1.0.9 245 12/29/2023
1.0.8 250 12/29/2023
1.0.7 238 12/28/2023
1.0.6 233 12/4/2023
Loading failed