【发布时间】:2011-05-06 00:29:24
【问题描述】:
我预计下一个将在一秒钟内打印 10 次“()”。但它在一秒钟后挂起。为什么?
adaptE $ fmap print $ filterE (const True) $ atTimes [0.1, 0.2 ..]
我发现它与filterE中使用的liftM有关:
filterE :: (Ord t, Bounded t) => (a -> Bool) -> EventG t a -> EventG t a
filterE p m = justE (liftM f m)
where
f a | p a = Just a
| otherwise = Nothing
我尝试使用fmap 重新实现filterE,它似乎有效。为什么?
标准filterE 是如何设计使用的?
我发现自己重新实现了reactive 包提供的许多标准功能(例如diffE、integrate)。这是否意味着该软件包有问题或我以错误的方式使用它?
谢谢!
【问题讨论】:
-
它们应该是一样的。但是
adaptE . fmap print $ atTimes [0.1, 0.2 .. 10]工作 10 秒,adaptE . liftM print $ atTimes [0.1, 0.2 .. 10]永远不会返回。为什么? -
reactive 有很多问题
-
@luqui,看来你的回答是唯一可以接受的)你能不能把它变成一个真实的答案,这样我才能接受?