LanguageExt.Process
1.7.1
dotnet add package LanguageExt.Process --version 1.7.1
NuGet\Install-Package LanguageExt.Process -Version 1.7.1
<PackageReference Include="LanguageExt.Process" Version="1.7.1" />
<PackageVersion Include="LanguageExt.Process" Version="1.7.1" />
<PackageReference Include="LanguageExt.Process" />
paket add LanguageExt.Process --version 1.7.1
#r "nuget: LanguageExt.Process, 1.7.1"
#:package LanguageExt.Process@1.7.1
#addin nuget:?package=LanguageExt.Process&version=1.7.1
#tool nuget:?package=LanguageExt.Process&version=1.7.1
C# functional language extensions and actor system
This library uses and abuses the features of C# 6 to provide a functional 'Base class library', that, if you squint, can look like extensions to the language itself. It also includes an 'Erlang like' process system (actors) that can optionally (if you also include LanguageExt.Process.Redis) persist messages and state to Redis (note you can use it without Redis for in-app messaging). The process system additionally supports Rx streams of messages and state allowing for a complete system of reactive events and message dispatch.
Lst<T> - Immutable list
Map<K,V> - Immutable map
Set<T> - Immutable set
Que<T> - Immutable queue
Stck<T> - Immutable stack
Option<T> - Option monad that can't be used with null values
OptionUnsafe<T> - Option monad that can be used with null values
Either<L,R> - Right/Left choice monad that won't accept null values
EitherUnsafe<L,R> - Right/Left choice monad that can be used with null values
Try<T> - Exception catching monad
TryOption<T> - Option monad with third state 'Fail' that catches exceptions
Reader<E,T> - Reader monad
Writer<O,T> - Writer monad
State<S,T> - State monad
Rws<E,O,S,T> - Reader/Writer/State monad
Monad transformers - A higher kinded type (ish)
Process library - Actor system. The same as Erlang processes for massive concurrency with state management.
Redis persistence - Persistence of the Process system message-queues and state, for robustness and inter-app communication.
Currying - https://en.wikipedia.org/wiki/Currying
Partial application - https://en.wikipedia.org/wiki/Partial_application
Memoization - https://en.wikipedia.org/wiki/Memoization
Improved lambda type inference - var add = fun( (int x, int y) => x + y)
IObservable<T> extensions
Bifunctors
Bitraversables
Bifoldables
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net is compatible. |
-
.NETFramework 4.5
- LanguageExt (>= 1.7.0)
- Newtonsoft.Json (>= 7.0.1)
- Rx-Main (>= 2.2.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|
== Core ==
* Added: Units of measure: Length, Velocity, Acceleation, Area and Time
Added: List.span - applied to a predicate and a list, returns a tuple where first element is longest prefix of elements that satisfy the predicate and second element is the remainder of the list.
* Added: List.tails function - returns all final segments of the list argument, longest first.
* Added: Applicative support for Option, OptionUnsafe, Either, EitherUnsafe, Try, TryOption, List, IEnumerable (Prelude.apply function or Apply extension method)
* Added: Support for arithmetic operators on all monadic types with provision of IAppendable, ISubtractable, IProductable, IDivisible and INumeric. Allowing for operations like this: Some(10) + Some(10) == Some(30), and List(1,2,3) + List(4,5,6) == List(1,2,3,4,5,6)
* Added: List.foldUntil, List.foldWhile
* Added: Functional version of 'using(...) { }' called 'use'
* Added: 'tryuse' which is a version of 'use' that returns a Try<T> where T is am IDisposable
* Added: Extension method: Try<T>.Use(), same as 'tryuse'
* Added: Try<T>.IfFail(Exception ex => ...)
* Added: Try<T>.IfFail().Match() - allows matching of Exception types as a single expression
Tuple<A,B> bi-functor, bi-foldable, bi-iterable
Tuple<A,B,C> tri-functor, tri-foldable, tri-iterable
* Added: Serializable attribute to Either, EitherUnsafe, Lst ListItem, Map, MapItem, Option, OptionUnsafe, Que, Stck,
* Moved Prelude.init, Prelude.initInfinite, Prelude.repeat to List
== Process system ==
* Strategy system - Decalarative way of dealing with Process failure
- Match on exceptions and map to Directives (Stop, Restart, Resume, Escalate)
- Map the Directives to MessageDirectives to decided on the fate of the failed message (Send to dead letters, Send to self (front or back of the queue), Send to supervisor, Send to specified Process)
* Session system - Allows consuming code to set a session-ID that is propagated throughout the system with the messages. Very useful for hooking up to authentication systems.
* Roles. Each node in a cluster must specify a role name.
* Process.ClusterNodes property - Has a map of alive cluster nodes and their roles.
* Routers - Processes that can auto-route messages to child processes or a provided set of processes. Default routers include:
- Broadcast
- Round-robin
- Random
- Least-busy
* Dispatchers - Like routers but without an actual Process. Dispatchers have a sender specified list of Processes to dispatch to, i.e. Dispatch.leastBusy(pid1, pid2, pid3). There are four default dispatchers:
- Broadcast
- Round-robin
- Random
- Least-busy
Bespoke dispacthers can be registered using Dispatch.register(...)
* Role dispatchers - Using a combination of Process.ClusterNodes and dispatchers, the Role dispatchers allow for ProcessIds to be built that refer to locations in the cluster by role. ie. Role.Broadcast["mail-server"]["user"]["smtp"] will create a ProcessId that looks like this: /disp/role-broadcast/user/smtp. Because it's a ProcessId it can be used with any of the existing functionality that accepts ProcessIds (tell, ask, subscribe, etc.) but has a behaviour baked in (broadcast in this case). So doing a tell will send to all 'smtp' Processes in the cluster.
There are several Role dispatchers:
- Broadcast
- Round-robin
- Random
- Least-busy
- First
- Second
- Third
- Last
* Death-watch system: Process.watch and Process.unwatch to get one Process watching for the death of another. Separate inbox called Terminated is used so that your primary inboxes can stay strongly typed.
* Process' setup functions are invoked immediately, rather than on their first message.
* More improvements to the F# API to bring it closer to parity with the C# API - this work is on-going.
* Process.js now has a Process.spawnView function (if knockout.js is in use) that allows for synchronisation of Process state and view state as well as hooking up event functions.
Documentation: More of it!
Thanks to la-yumba and jagged for their help with this release.