有没有“每n个时间单位重复一次动作”的动作?

问题描述 投票:0回答:1

在改进我正在试验的 Haskell 通知服务器时,我想出了这样的东西:

import Control.Concurrent (threadDelay)
import Control.Monad (forever)
repeatEvery :: Int -> IO () -> IO ()
repeatEvery time action = forever $ action >> threadDelay time

可以这样使用

repeatEvery oneSec $ do
  stuff

我想知道

repeatEvery
是否被某些图书馆暴露了。

我在 Hoogle 上通过搜索

a -> f b -> f b
没有找到类似的东西,但也许签名略有不同?

haskell functional-programming io-monad hoogle
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.