Skip to content

Prelude timeout does not use the HasTime<RT> runtime trait #1012

@timmi-on-rails

Description

@timmi-on-rails

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)

Metadata

Metadata

Assignees

Labels

enhancementv4Related to version < 5.0.0v5Related to version 5.0.0+

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions