LinqTools 5.1.1

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

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

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 229 12/13/2023
6.1.0 156 12/13/2023
6.0.0 290 12/10/2023
5.5.0 809 11/18/2023
5.4.0 479 11/16/2023
5.3.0 891 11/11/2023
5.2.0 870 8/14/2023
5.1.1 383 8/12/2023
5.1.0 386 8/12/2023
5.0.0 831 8/10/2023
4.2.0 198 8/9/2023
4.1.0 292 4/24/2023
4.0.0 949 4/9/2023
3.3.0 599 4/8/2023
3.2.0 204 4/8/2023
3.1.0 221 4/8/2023
3.0.0 200 4/8/2023
2.0.0 294 3/28/2023
1.3.0 262 3/26/2023
1.2.0 1,704 3/18/2023
1.1.0 428 3/15/2023
1.0.0 963 3/11/2023
0.0.1-alpha.5 108 3/8/2023
0.0.1-alpha.4 101 3/8/2023
0.0.1-alpha.3 92 3/8/2023
0.0.1-alpha.2 91 3/8/2023
0.0.1-alpha.1 92 3/8/2023

Instead of Nullables use Option