module Polysemy.Time.Sleep where import Control.Concurrent (threadDelay) import Polysemy.Time.Data.TimeUnit (MicroSeconds(MicroSeconds), TimeUnit, convert) uSleep :: Member (Embed IO) r => MicroSeconds -> Sem r () uSleep :: MicroSeconds -> Sem r () uSleep (MicroSeconds Int64 us) = IO () -> Sem r () forall (m :: * -> *) (r :: [(* -> *) -> * -> *]) a. Member (Embed m) r => m a -> Sem r a embed (Int -> IO () threadDelay (Int64 -> Int forall a b. (Integral a, Num b) => a -> b fromIntegral Int64 us)) tSleep :: Member (Embed IO) r => TimeUnit t => t -> Sem r () tSleep :: t -> Sem r () tSleep = MicroSeconds -> Sem r () forall (r :: [(* -> *) -> * -> *]). Member (Embed IO) r => MicroSeconds -> Sem r () uSleep (MicroSeconds -> Sem r ()) -> (t -> MicroSeconds) -> t -> Sem r () forall b c a. (b -> c) -> (a -> b) -> a -> c . t -> MicroSeconds forall a b. (TimeUnit a, TimeUnit b) => a -> b convert