Extensions to language-ext framework effects system that wraps the IO behaviours from the .NET BCL
$ dotnet add package LanguageExt.SysLanguageExt.Sys is the a wrapper around the System namespace IO functions and is part of the language-ext functional programming framework.
The framework uses and abuses the features of C# to provide a pure functional-programming 'Base Class Library' that, if you squint, can look like extensions to the language itself. The desire here is to make programming in C# much more robust by helping the engineer's inertia flow in the direction of declarative and pure functional code rather than imperative.
Using these techniques for large code-bases can bring tangible benefits to long-term maintenance by removing hidden complexity and by easing the engineer's cognitive load.
| Location | Feature | Description |
|---|---|---|
Core | Atom<A> | A lock-free atomically mutable reference for working with shared state |
Core | Ref<A> | An atomic reference to be used in the transactional memory system |
Core | AtomHashMap<K, V> | An immutable HashMap with a lock-free atomically mutable reference |
Core | AtomSeq<A> | An immutable Seq with a lock-free atomically mutable reference |
Core | VectorClock<A> | Understand distributed causality |
Core | VersionVector<A> | A vector clock with some versioned data |
Core | VersionHashMap <ConflictV, K, V> | Distrubuted atomic versioning of keys in a hash-map |
| Location | Feature | Description |
|---|---|---|
Core | Arr<A> | Immutable array |
Core | Seq<A> | Lazy immutable list, evaluate at-most-once - very, very fast! |
Core | Iterable<A> | Wrapper around IEnumerable with support for traits - enables the higher-kinded traits to work with enumerables. |
Core | Lst<A> | Immutable list - use Seq over Lst unless you need InsertAt |
Core | Map<K, V> | Immutable map |
Core | Map<OrdK, K, V> | Immutable map with Ord constraint on K |
Core | HashMap<K, V> | Immutable hash-map |
Core | HashMap<EqK, K, V> | Immutable hash-map with Eq constraint on K |
Core | Set<A> | Immutable set |
Core | Set<OrdA, A> | Immutable set with Ord constraint on A |
Core | HashSet<A> | Immutable hash-set |
Core | HashSet<EqA, A> | Immutable hash-set with Eq constraint on A |
Core | Que<A> | Immutable queue |
Core | Stck<A> | Immutable stack |
| Location | Feature | Description |
|---|---|---|
Core | Option<A> | Option monad |
Core | OptionT<M, A> | Option monad-transformer |
Core | Either<L,R> | Right/Left choice monad |
Core | EitherT<L, M, R> | Right/Left choice monad-transformer |
Core | Fin<A> | Error handling monad, like Either<Error, A> |
Core | FinT<M, A> | Error handling monad-transformer |
Core | Try<A> | Exception handling monad |
Core | TryT<M, A> | Exception handling monad-transformer |
Core | Validation<FAIL ,SUCCESS> | Validation applicative and monad for collecting multiple errors before aborting an operation |
Core | ValidationT<FAIL, M, SUCCESS> | Validation applicative and monad-transformer |
| Location | Feature | Description |
|---|---|---|
Core | Reader<E, A> | Reader monad |
Core | ReaderT<E, M, A> | Reader monad-transformer |
Core | Writer<W, A> | Writer monad that logs to a W constrained to be a Monoid |
Core | WriterT<W, M, A> | Writer monad-transformer |
Core | State<S, A> | State monad |
Core | StateT<S, M, A> | State monad-transformer |
| Location | Feature | Description |
|---|---|---|
Parsec | Parser<A> | String parser monad and full parser combinators library |
Parsec | Parser<I, O> | Parser monad that can work with any input stream type |
| Location | Feature | Description |
|---|---|---|
Core | Doc<A> | Produce nicely formatted text with smart layouts |
| Location | Feature | Description |
|---|---|---|
Core | Patch<EqA, A> | Uses patch-theory to efficiently calculate the difference (Patch.diff(list1, list2)) between two collections of A and build a patch which can be applied (Patch.apply(patch, list)) to one to make the other (think git diff). |
The traits are major feature of v5+ language-ext that makes generic programming with higher-kinds a reality. Check out Paul's series on Higher Kinds to get a deeper insight.
These work a little like NewType but they impart semantic meaning and some common operators for the underlying value.
| Location | Feature | Description |
|---|---|---|
Core | DomainType<SELF, REPR> | Provides a mapping from SELF to an underlying representation: REPR |
Core | Identifier <SELF> | Identifiers (like IDs in databases: PersonId for example), they are equivalent to DomaintType with equality. |
Core | VectorSpace<SELF, SCALAR> | Scalable values; can add and subtract self, but can only multiply and divide by a scalar. Can also negate. |
Core | Amount <SELF, SCALAR> | Quantities, such as the amount of money in USD on a bank account or a file size in bytes. Derives VectorSpace, IdentifierLike, DomainType, and is orderable (comparable). |
Core | LocusLike <SELF, SCALAR, DISTANCE> | Works with space-like structures. Spaces have absolute and relative distances. Has an origin/zero point and derives DomainType, IdentifierLike, AmountLike and VectorSpace. DISTANCE must also be an AmountLike<SELF, REPR, SCALAR>. |