Skip to content

Language-Ext Version 1.5 release

Compare
Choose a tag to compare
@louthy louthy released this 22 Sep 23:17

This is a major new release of Language-Ext with myriad new features and improvements. Much of this release is about refining and standardising the API. This is the first stable release of the LanguageExt.Process system (Actor system), LanguageExt.Process.FSharp (F# API for LanguageExt.Process), LanguageExt.ProcessJS (Javascript Actor system that allows seamless actor messaging from server to client), and LanguageExt.Process.Redis (for intra-system messaging and message/state persistence).

Standardisation comes in the form:

  • Making all constructor functions start with a capital letter
  • Making all fold and scan functions use the same fold function signature
  • Creating a common set of functions that all of the monad types implement

So:

  • tuple becomes Tuple
  • list becomes List
  • map becomes Map
  • cons becomes Cons
  • etc.

This makes the constructor functions consistent with Some, None, Left, Right, ... The only exception to this is the unit constructor, which stays as-is.

We also bring in a concept of a type of a 'higher kinded type' for all of the monadic types. It's not quite as effective or refined as a Haskell HKT, but it does create a standard interface (through extension methods) for all of the monadic types. The standard interface includes the following functions:

  • Sum
  • Count
  • Bind
  • Exists
  • Filter
  • Fold
  • ForAll
  • Iter
  • Map
  • Lift / LiftUnsafe
  • SelectMany
  • Select
  • Where

Because of this standardised interface, it's also possible to use monad transformer functions (for up to a two-level deep generic monad-type):

  • SumT
  • BindT
  • CountT
  • ExistsT
  • FilterT
  • FoldT
  • ForAllT
  • IterT
  • MapT

i.e.

    var list = List(Some(1), None, Some(2), None, Some(3));    // Lst<Option<int>>

    var presum = list.SumT();                                // 6

    list  = list.MapT( x => x * 2 );

    var postsum = list.SumT();                               // 12

New types

  • Map<K,V> - Replacement for ImmutableDictionary<K,V> that uses an AVL tree implementation
  • Lst<T> - Wrapper for ImmutableList<T>
  • Set<T> - Wrapper for ImmutableSet<T>
  • Try<T> - Like TryOption<T> but without the optional return value
  • RWS<E,W,S> - Reader/Writer/State monad
  • ExceptionMatch - Used for new Exception extension method Match for pattern matching on exception types.
  • ActionObservable<T> - Used by IObservable<T> extension method PostSubscribe. Allows an action to be executed post-subscription.

New functions

  • static Process functions in LanguageExt.Process
  • par - Partial application
  • curry - Currying
  • random - Thread safe random number generator
  • ifSome added for TryOption - dispatches an action if the TryOption is in a Some state

Improvements

  • Improved Unit type - Implemented IEquatable<Unit> and equality operator overloads
  • Improved IComparable and IEquatable support for Option and Either types

Breaking changes

  • Standardised the fold and scan delegates to Func<S,T,S>

Deprecated (made obsolete)

  • tuple - becomes Tuple
  • query - becomes Query
  • map - becomes Map
  • list - becomes List
  • array - becomes Array
  • stack - becomes Stack
  • failure - becomes ifNone / ifLeft
  • Prelude.empty - becomes List.empty / Set.empty / Map.empty
  • cons - becomes Cons
  • range - becomes Range
  • with - becomes map

Nuget: