LanguageExt

v0.1.1·Updated 2024-01-29

C# Functional Programming Language Extensions

Screenshots 2 screenshots

About this mod Author’s original text

C# Functional Programming Language Extensions

=============================================

This library uses and abuses the features of C# to provide a 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 reliable and to make the engineer's inertia flow

in the direction of declarative and functional code rather than imperative.

__Author on...__

  • __twitter:__ @paullouth
  • __mastodon:__ @louthy@4four.org

__Paul Louth discussing FP for the GitHub ReadME project__

Contents

  • Reference
  • Nu-get package
  • Code-gen setup
  • Unity
  • Getting started
  • Prologue
  • Features
  • Functional effects and IO
  • Atomic concurrency, shared state, and collections
  • Immutable collections
  • Optional and Alternative value monads
  • State managing monads
  • Parser combinators
  • Type aliasing
  • Records, Unions, Free Monads, Lenses - Code Generation
  • Pretty: Produce nicely formatted text with smart layouts
  • Make C# better: memoisation, currying, partial application, Nullable, Task, and IQueryable extensions
  • Poor tuple support
  • Null reference problem
  • Option
  • Lack of lambda and expression inference
  • Void isn't a real type
  • Mutable lists and dictionaries
  • Lists
  • List pattern matching
  • Maps
  • Difficulty in creating immutable record types
  • Transformation of immutable types
  • [[With]](#with)
  • Transformation of nested immutable types with Lenses
  • [[WithLens]](#withlens)
  • The awful 'out' parameter
  • The lack of ad-hoc polymorphism
  • Num
  • Eq
  • Ord
  • Semigroup
  • Monoid
  • Monad
  • Transformer types
  • Contributing & Code of Conduct

Reference

  • API Reference
  • Issues that contain documentation and examples

Nu-get

Nu-get package | Description

---------------|-------------

LanguageExt.Core | All of the core types and functional 'prelude'. __This is all that's needed to get started__.

LanguageExt.Transformers | For every combination of monadic type M> (i.e. Seq>), this package provides the following extension methods: ApplyT, AppendT, BindT, CompareT, CountT, EqualsT, ExistsT, ForAllT, FoldT, FoldBackT, FilterT, IterT, MapT, PlusT, ProductT, SubtractT, DivideT, and SumT. Which makes it much easier to work with those nested types (no need to manually unpack the bound values)

LanguageExt.FSharp | F# to C# interop package. Provides interop between the LanguageExt.Core types (like Option, List and Map) to the F# equivalents, as well as interop between core BCL types and F#

LanguageExt.Parsec | Port of the Haskell parsec library

LanguageExt.Rx | Reactive Extensions support for various types within the Core

LanguageExt.Sys | Provides an Aff and Eff wrapper around the.NET System namespace making common IO operations pure and unit-testable

LanguageExt.SysX | As above, but provides.NET5+ specific features

LanguageExt.CodeGen | Used to generate records, unions, lenses, and With functions automagically.

Code-gen setup

To use the code-generation features of language-ext (which are totally optional by the way), then you must include the LanguageExt.CodeGen package into your project.

To make the reference build and design time only (i.e. your project doesn't gain an additional dependencies because of the code-generator), open up your csproj and set the PrivateAssets attribute to all:

Obviously, update the Version attributes to the appropriate values. Also note that you will probably need the latest VS2019+ for this to work. Even early versions of VS2019 seem to have problems.

There's more information on the code-gen features on the wiki

Unity

This library seems compatible on the latest (at the time of writing) Unity 2018.2 with __incremental compiler__ (which enables C# 7), so it should work well once Unity has official support for C# 7 on upcoming 2018.3.

In the meanwhile, you can install incremental compiler instead.

If you are concerned about writing functionally and the possible performance overheads then p

Install & use Install: BepInEx plugin

  1. The archive from playbuff is the mod itself — usually a BepInEx plugin (a .dll or a plugin folder once unzipped).
  2. Recommended: use a community mod manager (such as r2modman) — pick this game, import the mod, and the manager sets up BepInEx and its dependencies for you.
  3. Manual route: install the BepInEx loader in the game folder, then drop the unzipped .dll or plugin folder into BepInEx/plugins/.
  4. Launch the game — the BepInEx console logs every plugin it loads; seeing this mod in the log means it is installed.

Mods with listed dependencies need those installed too, or they will not load. Options are usually changed in-game or in the plugin's config file.

File & checksum

Filename
LanguageExt-0.1.1.zip
File size
3.6 MiB