Skip to content

`Sys.IO` improvements / Triaged issues + fixes release

Pre-release
Pre-release
Compare
Choose a tag to compare
@louthy louthy released this 22 Oct 14:07
· 99 commits to main since this release

Sys.IO improvement

The Sys.IO functions were generalised to support any monad that has the correct Has traits. However, this added a burden to any users of Eff and Aff from v4 of language-ext.

For example, this in v4:

    Console<RT>.writeLine(text)

Would become this in v5:

    Console<Eff<RT>, RT>.writeLine(text)

That works well when you're write entirely generalised IO code, like you see in the Newsletter sample project.

Writing this:

    Console<M, RT>.writeLine(text)

Is clearly not much worse than before. And adds lots of possibilities for writing your IO functions once and have them work with all IO based monads. But, this Console<Eff<RT>, RT>.writeLine(text) is quite ugly to look at in my humble opinion. There's too much clutter and it shows up on every line of IO you write, which doesn't feel good.

So, as Eff<RT, A> is an important type for doing dependecy-injection based IO, I have added Eff specific versions for every static class in the Sys library.

So, for example, as well as Console<M, RT>, there is also a Console<RT> which only works with the Eff<RT, A> monad. This allows existing code that uses Eff<RT, A> to work without a change.

I'm not a huge fan of doubling up the work like this, but I think this is a pragmatic solution that works without much drama.

Fixes and Updates:

  • Unit made into a Monoid
  • Option<A> made into a Monoid
  • The ToEnumerable extension for Foldable has been renamed to ToIterable (it was missed on the previous refactor)
  • StreamT internals made lazy
    • Allows the removal of bespoke types that deal only with IEnumerable and IAsyncEnumerable
  • HeadUnsafe removed from StreamT
    • HeadOrFail extension to StreamT added. Only works with Fallible monads.
  • Fix for FileIO move missing? #1174
  • Removed MemoryFS, replaced with use of /tmp as a virtual file-system. Fixes:

Additions, but not ready for primetime

  • Source<A> - a source of events that can be subscribed to. Subscriptions yield a StreamT