LinqTools 6.2.0

dotnet add package LinqTools --version 6.2.0                
NuGet\Install-Package LinqTools -Version 6.2.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="6.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LinqTools --version 6.2.0                
#r "nuget: LinqTools, 6.2.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=6.2.0

// Install LinqTools as a Cake Tool
#tool nuget:?package=LinqTools&version=6.2.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 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. 
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 233 12/13/2023
6.1.0 160 12/13/2023
6.0.0 294 12/10/2023
5.5.0 813 11/18/2023
5.4.0 488 11/16/2023
5.3.0 895 11/11/2023
5.2.0 874 8/14/2023
5.1.1 387 8/12/2023
5.1.0 390 8/12/2023
5.0.0 835 8/10/2023
4.2.0 202 8/9/2023
4.1.0 296 4/24/2023
4.0.0 955 4/9/2023
3.3.0 603 4/8/2023
3.2.0 209 4/8/2023
3.1.0 225 4/8/2023
3.0.0 204 4/8/2023
2.0.0 299 3/28/2023
1.3.0 266 3/26/2023
1.2.0 1,708 3/18/2023
1.1.0 432 3/15/2023
1.0.0 967 3/11/2023
0.0.1-alpha.5 110 3/8/2023
0.0.1-alpha.4 103 3/8/2023
0.0.1-alpha.3 94 3/8/2023
0.0.1-alpha.2 93 3/8/2023
0.0.1-alpha.1 94 3/8/2023

.NET 8, nothing as literal, Result.IsOK