LanguageExt 0.0.14-beta
See the version list below for details.
dotnet add package LanguageExt --version 0.0.14-beta
NuGet\Install-Package LanguageExt -Version 0.0.14-beta
<PackageReference Include="LanguageExt" Version="0.0.14-beta" />
paket add LanguageExt --version 0.0.14-beta
#r "nuget: LanguageExt, 0.0.14-beta"
// Install LanguageExt as a Cake Addin
#addin nuget:?package=LanguageExt&version=0.0.14-beta&prerelease
// Install LanguageExt as a Cake Tool
#tool nuget:?package=LanguageExt&version=0.0.14-beta&prerelease
Using and abusing the features of C# 6 to provide functions and types, which, if you squint, can look like extensions to the language itself.
This package brings functional helpers for classic C# problems:
Poor tuple support
Null reference problem
Lack of lambda and expression inference
Void isn't a real type
Mutable lists and dictionaries
The awful 'out' parameter.
Features include:
Option<T>
OptionUnsafe<T>
TryOption<T>
Either<R,L>
EitherUnsafe<R,L>
List
Map
Queue
Set
Memoization
Tuple
Unit
And more...
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net is compatible. |
-
.NETFramework 4.5
- System.Collections.Immutable (>= 1.1.32-beta)
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.1.2-beta | 103 | 4/16/2015 |
0.1.1-beta | 66 | 2/19/2015 |
0.0.14-beta | 40 | 2/4/2015 |
0.0.12-beta | 42 | 1/15/2015 |
0.0.11-beta | 35 | 1/15/2015 |
0.0.10-beta | 38 | 1/15/2015 |
0.0.8-beta | 123 | 11/23/2014 |
0.0.7-beta | 64 | 11/22/2014 |
0.0.6-beta | 65 | 11/22/2014 |
0.0.4-beta | 71 | 11/21/2014 |
0.0.3-beta | 124 | 11/20/2014 |
0.0.2-beta | 193 | 11/19/2014 |
0.0.1-beta | 262 | 11/19/2014 |
### Operators
`None` and `Left` coalescing using the logical-or operator.
This means chaining of optional values with defaults:
Option<int> optional1 = None;
Option<int> optional2 = None;
var res = optional1 || optional2 || "Default";
// Some("Default")
This also means you can use them in LINQ expressions where `from` is logical-AND and `||` is logical-OR:
Option<int> optional1 = None;
Option<int> optional2 = Some(10);
Option<int> optional3 = Some(20);
var res = from x in optional1 || optional2
from y in optional3
select x + y;
// Some(30)
`true` and `false` operators implemented for option and either types.
var optional = Some(123);
if( optional )
{
// true
}
`==` and `!=` operators implemented for option and either types:
var optional = Some(123);
if( optional == 123 )
{
// true
}
Option<int> optional = None;
if( optional == None )
{
// true
}
### With
`with(Tuple,..)` and `With(Tuple,..)` are now `map(Tuple,..)` and `Map(Tuple,..)`. They were poorly named, these are more consistent with their action. The `with` functions that take up to 5 parameters are also renamed `map`.
The old `with` functions have been marked `[Obsolete]`
Thanks to @tomaszpolanski for the feedback
https://github.com/louthy/language-ext/issues/15
### Optional
Added `Optional`, it will take `T` or `null` and return a `Some(T)` or `None` respectively. This is for where you want to be explicit about the conversion from `T` to `Some(T)|None`, and for when the type system complains at you (in the branches of a ternary operator for example):
string x = GetValueFromNonTrustedAPI();
return Optional(x);
Thanks to @tejacques for the feedback:
https://github.com/louthy/language-ext/issues/12
... and Various bug fixes