Skip to content

Aff and Eff monad updates (breaking changes)

Compare
Choose a tag to compare
@louthy louthy released this 24 Jun 01:34
· 1016 commits to main since this release

I've done some refactoring of the Aff and Eff monads as I slowly progress toward a v4.0 release of language-ext:

  • RunIO has been renamed to Run
  • HasCancel has been rationalised to only use non-Eff and non-Aff properties
    • It was a mistake to use them, I should have just used regular properties and then made access via static functions
    • This has now been done and should make it a bit more obvious how to use when building your own runtimes
  • Support for MapAsync on the Eff monads
    • That means we don't need both a Aff and Eff property in the Has* traits, as an Eff can be MapAsyncd into an Aff efficiently
    • So traits now should only return something like Eff<RT, FileIO> FileEff (obviously different types based on your trait)
  • The wrappers for the .NET System namespace have now been factored out into a new library LanguageExt.Sys
    • The naming wasn't great, and it was clear it was going to get pretty messy as I wrapped more of the System IO operations
    • Also, there's a chance you wouldn't want to use the implementations I have built, so having the main namespace cluttered with IO traits and types that you might not need was a bit ugly.
  • The default 'live' runtime has also been factored out
  • A new test runtime has been added - for unit testing
    • A new built-in mocked in-memory file-system - this allows unit tests to work with files without having to physically create them on a disk
    • A new built-in mocked in-memory console - this allows unit tests to mock key-presses in a console, as well as the option the look at the in-memory console buffer to assert correct values being written
    • A time provider - allows the system clock to appear to run from any date, or even be frozen in time
    • An in-memory mocked 'System.Environment'

Finally, I'm starting to document the Aff and Eff usage. This will be fleshed out more over the next few weeks.

All deployed to nu-get now.