Prelude timeout does not use the HasTime<RT> runtime trait
Author: timmi-on-railsCreated Mar 17, 2022Updated Oct 24, 2024
Labelsenhancementv5v4
I was surprised that the runtime-dependent timeout implementation does not utilize the HasTime<RT> trait for the internal timeout task.
Current version
// signature (see https://github.com/louthy/language-ext/blob/main/LanguageExt.Core/Effects/Aff/Prelude/Aff.Prelude.cs#L228)
public static Aff<RT, A> timeout<RT, A>(TimeSpan timeoutDelay, Aff<RT, A> ma) where RT : struct, HasCancel<RT>
// timeout task implementation (see https://github.com/louthy/language-ext/blob/main/LanguageExt.Core/Effects/Aff/Aff.cs#L174)
var delay = Task.Delay(timeoutDelay, delayTokSrc.Token);What I expected
// signature
public static Aff<RT, A> timeout<RT, A>(TimeSpan timeoutDelay, Aff<RT, A> ma) where RT : struct, HasCancel<RT>, HasTime<RT>
// timeout task implementation
// something like...
var delay = ?...? env.TimeEff.Map(timeIO => timeIO.SleepFor(timeoutDelay, delayTokSrc.Token)) ?...?
Is my expectation unusual?
(If not, any change is probably a breaking change, so it comes down to extending the method documentation and maybe provide a timeout2 function)
Source: louthy/language-ext