![]() |
VOOZH | about |
dotnet add package SharpX --version 8.3.6
NuGet\Install-Package SharpX -Version 8.3.6
<PackageReference Include="SharpX" Version="8.3.6" />
<PackageVersion Include="SharpX" Version="8.3.6" />Directory.Packages.props
<PackageReference Include="SharpX" />Project file
paket add SharpX --version 8.3.6
#r "nuget: SharpX, 8.3.6"
#:package SharpX@8.3.6
#addin nuget:?package=SharpX&version=8.3.6Install as a Cake Addin
#tool nuget:?package=SharpX&version=8.3.6Install as a Cake Tool
SharpX is derived from CSharpx 2.8.0-rc.2 (which was practically a stable) and RailwaySharp 1.2.2.
While both projects were meant mainly for source inclusion, SharpX is designed to be pulled from NuGet.
The library contains functional types and other utilities, including test oriented tools. It follows the don't reinvent the wheel philosophy. This project was originally inspired by Real-World Functional Programming and includes code from MoreLINQ.
You can install it via NuGet:
$ dotnet add package SharpX --version 8.3.6
Determining projects to restore...
...
All types are available in the root namespace. Extension methods (except the very specific ones) are in SharpX.Extensions.
SharpX.FsCheck contains FsCheck generators for property-based testing.
'T option / Haskell data Maybe a = Just a | Nothing type.var greet = true;
var value = greet ? "world".ToMaybe() : Maybe.Nothing<string>();
value.Match(
who => Console.WriteLine($"hello {who}!"),
() => Environment.Exit(1));
var result1 = (30).ToJust();
var result2 = (10).ToJust();
var result3 = (2).ToJust();
var sum = from r1 in result1
from r2 in result2
where r1 > 0
select r1 - r2 into temp
from r3 in result3
select temp * r3;
var value = sum.FromJust(); // outcome: 40
var maybeFirst = new int[] {0, 1, 2}.FirstOrNothing(x => x == 1)
// outcome: Just(1)
data Either a b = Left a | Right b type.Choice<'T, 'U>.Right case hold the value and Left keep track of error or similar data.Result.This type was originally present in RailwaySharp. Check the test project to see a more complete usage example.
public static Result<Request, string> ValidateInput(Request input)
{
if (input.Name == string.Empty) {
return Result<Request, string>.FailWith("Name must not be blank");
}
if (input.EMail == string.Empty) {
return Result<Request, string>.FailWith("Email must not be blank");
}
return Result<Request, string>.Succeed(input);
}
var request = new Request { Name = "Giacomo", EMail = "gsscoder@gmail.com" };
var result = Validation.ValidateInput(request);
result.Match(
(x, msgs) => { Logic.SendMail(x.EMail); },
msgs => { Logic.HandleFailure(msgs) });
Unit is similar to void but, since it's a real type. void is not, in fact you can't declare a variable of that type. Unit allows the use functions without a result in a computation (functional style). It's essentially F# unit and Haskell Unit.// prints each word and returns 0 to the shell
static int Main(string[] args)
{
var sentence = "this is a sentence";
return (from _ in
from word in sentence.Split()
select Unit.Do(() => Console.WriteLine(word))
select 0).Distinct().Single();
}
FSharpResult<T, TError> in simple and functional for other .NET languages.// pattern match like
var result = Query.GetStockQuote("ORCL");
result.Match(
quote => Console.WriteLine($"Price: {quote.Price}"),
error => Console.WriteLine($"Trouble: {error}"));
// mapping
var result = Query.GetIndex(".DJI");
result.Map(
quote => CurrencyConverter.Change(quote.Price, "$", "€"));
Strings class.Console.WriteLine(
"\t[hello\world@\t".Sanitize(normalizeWhiteSpace: true));
// outcome: ' hello world '
Console.WriteLine(
"I want to change a word".ApplyAt(4, word => word.Mangle()));
// outcome like: 'I want to change &a word'
Choose using Maybe):var numbers = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
var evens = numbers.Choose(x => x % 2 == 0
? x.ToJust()
: Maybe.Nothing<int>());
// outcome: {0, 2, 4, 6, 8}
var sequence = new int[] {0, 1, 2, 3, 4}.Intersperse(5);
// outcome: {0, 5, 1, 5, 2, 5, 3, 5, 4}
var element = sequence.Choice();
// will choose a random element
var sequence = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }.ChunkBySize(3);
// outcome: { [0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10] }
Tool icon designed by Cattaleeya Thongsriphong from The Noun Project
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 netstandard2.1 is compatible. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 2 NuGet packages that depend on SharpX:
| Package | Downloads |
|---|---|
|
PickAll
.NET agile and extensible web searching API |
|
|
PeachClient
Unofficial client library for the Peach Bitcoin API |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 8.3.6 | 1,081 | 4/6/2025 |
| 8.3.4 | 309 | 3/29/2025 |
| 8.3.2 | 270 | 3/29/2025 |
| 8.3.0 | 717 | 2/23/2025 |
| 8.1.0 | 275 | 2/9/2025 |
| 8.0.0 | 271 | 2/5/2025 |
| 6.4.6 | 1,003 | 6/1/2024 |
| 6.4.2 | 495 | 1/14/2024 |
| 6.3.6 | 360 | 12/18/2023 |
| 6.3.2 | 372 | 9/28/2023 |
| 6.3.0 | 307 | 8/20/2023 |
| 6.2.1 | 985 | 5/26/2023 |
| 6.2.0 | 313 | 5/26/2023 |
| 6.1.0 | 356 | 4/25/2023 |
| 6.0.3 | 378 | 4/20/2023 |
| 6.0.2 | 533 | 4/16/2023 |
| 6.0.1 | 364 | 4/15/2023 |
| 6.0.0-preview.1 | 549 | 3/29/2022 |
| 1.1.11 | 4,451 | 3/20/2022 |