IO refactor continued #1430
louthy
announced in
Announcements
Replies: 1 comment 1 reply
-
|
Would it be a useful contribution to create a PR in order to add unit tests, given the last point raised? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
IO<A>The work has continued following on from the last
IOrefactor release. The previous release was less about optimisation and more about correctness, this release is all about making theasync/awaitstate-machines disappear for synchronous operations.RunandRunAsyncmethods have been updated to neverawait. If at any point an asynchronous DSL entry is encountered then processing is deferred toRunAsyncInternal(which does useawait). Because,RunAsyncusesValueTaskit's possible to run synchronous processes with next to zero overhead and still resolve to a fully asynchronous expression when one is encountered.IOFold,IOFoldWhile,IOFoldUntil(see 'Folding')Final<F>(seeFinal<F>)TODO
Repeat*andRetry*- then all core capabilities can run synchronously if they are composed entirely of synchronous components.Folding
The standard
FoldWhileandFoldUntilbehaviour has changed forIO(and will change for allFoldWhileandFoldUntileventually: it dawned on me that it was a bit of a waste thatFoldWhilewas equivalent toFoldUntilbut with anoton the predicate.So, the change in behaviour is:
FoldUntilpredicate test (and potential return) is run after the fold-delegate has been run (so it gets the current-value + the fold-delegate updated-state).FoldWhilepredicate test (and potential return) is run before the fold-delegate is run (so it gets the current-value + the current-state).The benefit of this approach is that you can stop a fold-operation running if the state is already 'bad' with
FoldWhile, whereas withFoldUntilyou can exit once the fold-operation makes the state 'bad'. The difference is subtle, but it does give additional options.Final<F>traitFinal<F>is a new trait-type to supporttry / finallybehaviour. This has been implemented forIOfor now. This will expand out to other types later. You can see from the updated implementation ofBrackethow this works:It's still early for this type, but I expect to provide
@finallymethods that work a bit like the@catchmethods.Unit tests for
IOOne of the things that's holding up the full-release of
v5(other than the outstanding bugs in Pipes) is the lack of unit-tests for all of the new functionality. So, I've experimented using Rider's AI assistant to help me write the unit-tests. It's fair to say that it's not too smart, but at least it wrote a lot of the boilerplate. So, once I'd fixed up the errors, it was quite useful.It's debatable whether it was much quicker or not. But, I haven't really spent any time with AI assistants, so I guess it might just be my inexperience of prompting them. I think it's worth pursuing to see if it can help me get through the unit-tests that are needed for
v5.This discussion was created from the release IO refactor continued.
Beta Was this translation helpful? Give feedback.
All reactions