o-clock icon indicating copy to clipboard operation
o-clock copied to clipboard

Explore more API design choices for 'threadDelay'

Open chshersh opened this issue 7 years ago • 1 comments

Currently we have several ways to call threadDelay function:

threadDelay $ sec 5
threadDelay (5 :: Time Second)
threadDelay @Second 5

But we can have more! We can have other functions so it would be possible to write something like this:

timeDelay1 5 sec
timeDelay2 5 @Second

Does it look convenient? What do you think?

Inspired by this tweet:

  • https://twitter.com/Axman6/status/959196484498472965

chshersh avatar Feb 02 '18 10:02 chshersh

I think we can have both threadDelay @Second 5 and threadDelay 5 @Second work if we change the type signature like this:

threadDelay :: forall (unit :: Rat) m. (KnownDivRat unit Microsecond, MonadIO m) => Time unit -> forall unit'. (unit ~ unit') => m () 

I am not sure it's worth to complicate it for this minor convenience.

int-index avatar Feb 02 '18 10:02 int-index