LinqTools 5.5.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package LinqTools --version 5.5.0                
NuGet\Install-Package LinqTools -Version 5.5.0                
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="LinqTools" Version="5.5.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LinqTools --version 5.5.0                
#r "nuget: LinqTools, 5.5.0"                
#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 LinqTools as a Cake Addin
#addin nuget:?package=LinqTools&version=5.5.0

// Install LinqTools as a Cake Tool
#tool nuget:?package=LinqTools&version=5.5.0                

LinqTools

Extensions for LINQ

Overview

  • Extension functions to make Nullable a Monad/Functor
  • Extension functions to make Async Function a Monad/Functor
  • Ohter Tools usable for fluent syntax

Option< T >

There are Extension Functions for Option to make them Monads/Functors:

  • Select
  • SelectMany

If you are not sure, if an object is null although the compiler says no, you can create a Nullable from an apparently not Nullable with

static T? AsNullable<T>(this T t)

With the extension functions you can work with Options as if they were the containing type:

var res = (from n in teststr
           from m in GetFirstStringChecked(n) 
           where m.Length == 9
           from p in ThrowIfNull(m)
           select p)
                .GetOrDefault("Nothing");

As soon as a function returns None, all further processing is skipped.

Result Monad/Functor

There is a Result Monad/Functor, containing either an Ok value or an Error value. You can transform Results with LINQ queries like:

var test = from n in await Process.RunAsync("lsblk", "--bytes --output SIZE,NAME,LABEL,MOUNTPOINT,FSTYPE")
           let driveLines = n.Split('\n', StringSplitOptions.RemoveEmptyEntries)
           let titles = driveLines[0]
           let positions = new[]
           {
               0,
               titles.IndexOf("NAME"),
               titles.IndexOf("LABEL"),
               titles.IndexOf("MOUNT"),
               titles.IndexOf("FSTYPE")
           }
           select driveLines
                    .Skip(1)
                    .Select(n => CreateRootItem(n, positions))
                    .ToArray();
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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 (1)

Showing the top 1 NuGet packages that depend on LinqTools:

Package Downloads
GtkDotNet

.NET 6 Bindings for GTK 3

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
6.2.0 227 12/13/2023
6.1.0 154 12/13/2023
6.0.0 288 12/10/2023
5.5.0 807 11/18/2023
5.4.0 478 11/16/2023
5.3.0 889 11/11/2023
5.2.0 868 8/14/2023
5.1.1 379 8/12/2023
5.1.0 384 8/12/2023
5.0.0 829 8/10/2023
4.2.0 196 8/9/2023
4.1.0 290 4/24/2023
4.0.0 947 4/9/2023
3.3.0 597 4/8/2023
3.2.0 203 4/8/2023
3.1.0 219 4/8/2023
3.0.0 198 4/8/2023
2.0.0 293 3/28/2023
1.3.0 260 3/26/2023
1.2.0 1,702 3/18/2023
1.1.0 426 3/15/2023
1.0.0 961 3/11/2023
0.0.1-alpha.5 106 3/8/2023
0.0.1-alpha.4 99 3/8/2023
0.0.1-alpha.3 90 3/8/2023
0.0.1-alpha.2 89 3/8/2023
0.0.1-alpha.1 90 3/8/2023

Simple SelectMany for Result, functional if