Aff, Eff, AtomHashMap, TrackingHashMap + fixes [RTM] #1030
louthy
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Language-ext had been in beta for a few months now. Today we go back to full 'RTM' mode.
The recent changes are:
AtomHashMap
andRef
change-trackingA major new feature that allows for tracking of changes in an
AtomHashMap
or aRef
(using STM). TheChange
event publishesHashMapPatch<K, V>
which will allow access to the state of the map before and after the change, as well as aHashMap<K, Change<V>>
which describes the transformations that took place in any transactional event.In the
LanguageExt.Rx
project there's various observable stream extensions that leverage theChange
event:OnChange()
- which simply streams theHashMapPatch<K, V>
OnEntryChange()
- which streams theChange<V>
for any key within the mapOnMapChange()
- which streams the latestHashMap<K, V>
snapshotRef
which represents a single value in the STM system, has a simplerChange
event that simply streams the latest value. It also has anRx
extension, calledChange()
.Documented in previous beta release notes
TrackingHashMap<K, V>
This is a new immutable data-structure which is mostly a clone of
HashMap
; but one that allows for changes to be tracked. This is completely standalone, and not related to the AtomHashMap in any way other than it's used by theAtomHashMap.Swap
method. And so, this has use-cases of its own.Changes are tracked as a
HashMap<K, Change<V>>
. That means there's at most one change-value stored per-key. So, there's no risk of an ever expanding log of changes, because there is no log! The changes that are tracked are from the 'last snapshot point'. Which is from the empty-map or from the last state where trackingHashMap.Snapshot()
is called.Documented in previous beta release notes
Fixes to the
Aff
andEff
systemThe
Aff
andEff
system had some unfortunate edge-cases due to the use of memoisation by-default. The underlying system has been simplified to be more of a standard reader-monad without memoisation. You can still memoise if needed by calling:ma.Memo()
.Breaking change: Both
Clone
andReRun
have been removed, as they are now meaningless.New package
LanguageExt.SysX
- for .NET5.0+ featuresThe
LanguageExt.Sys
package is a wrapper for .NET BCL IO functionality, for use with the runtimeEff
andAff
monads. This is going to stay asnetstandard2.0
for support of previous versions of the .NET Framework and .NET Core. This new package adds features that are fornet5.0+
.The first feature to be supported is the
Activity
type for Open-Telemetry support.ScheduleAff
andScheduleEff
usage was inconsistentDepending on the monad they were used with, you might see a 'repeat' that was 1 greater than it should have been. This is now fixed.
Lazy
Seq
equality fixUnder certain rare circumstances it was possible for the equality operator to error with a lazy
Seq
. Fix from @StefanBertels - thanks!No more empty array allocations
It seams c# isn't smart enough to turn a
new A[0]
into a non-allocating operation. And so they have all been replaced withArray.Empty()
. Fix from @timmi-on-rails - thanks!Any problems, please report them in the Issues as usual. Paul 👍
This discussion was created from the release Aff, Eff, AtomHashMap, TrackingHashMap + fixes [RTM].
Beta Was this translation helpful? Give feedback.
All reactions