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 189 12/13/2023
6.1.0 109 12/13/2023
6.0.0 221 12/10/2023
5.5.0 669 11/18/2023
5.4.0 367 11/16/2023
5.3.0 658 11/11/2023
5.2.0 767 8/14/2023
5.1.1 348 8/12/2023
5.1.0 345 8/12/2023
5.0.0 757 8/10/2023
4.2.0 162 8/9/2023
4.1.0 239 4/24/2023
4.0.0 838 4/9/2023
3.3.0 527 4/8/2023
3.2.0 177 4/8/2023
3.1.0 189 4/8/2023
3.0.0 171 4/8/2023
2.0.0 260 3/28/2023
1.3.0 232 3/26/2023
1.2.0 1,608 3/18/2023
1.1.0 382 3/15/2023
1.0.0 878 3/11/2023
0.0.1-alpha.5 96 3/8/2023
0.0.1-alpha.4 91 3/8/2023
0.0.1-alpha.3 81 3/8/2023
0.0.1-alpha.2 80 3/8/2023
0.0.1-alpha.1 81 3/8/2023

.NET 8, nothing as literal, Result.IsOK