【发布时间】:2019-05-07 23:53:24
【问题描述】:
我正在尝试在 Idris 中编写 FRP 库。该库设计为在单线程环境中运行。未来实现Monad 和Align。我想用这些简化的类型签名来实现函数:
createFutureResolveLater : (Future a, a -> IO ()) -- later time
createFutureResolveNow : a -> IO (Future a) -- current time
pure : a -> Future a -- before everything
align : Future a -> Future a -> Future (These a b) -- min of two times
join : Future (Future a)) -> Future a -- max of two times
exeEvent : Future (IO a) -> IO (Future a) -- ??
simultaneous : Future a -> Future b -> Future Bool -- min of two times
subFuture : Future a -> (a -> IO ()) -> IO ()
在我看来很明显
simultaneous a a, simultaneous a (fmap f a), etc.
应该是一个解析为真的未来。
在
do
oe <- exeEvent ie
let s = simultaneous oe ie
...
应该解析为真吗?
在反应香蕉中,s 是假的。见http://hackage.haskell.org/package/reactive-banana-1.2.1.0/docs/Reactive-Banana-Frameworks.html中的mapEventIO
在反射中,s 也很可能是错误的。请参阅https://daig.github.io/reflex/Reflex-PerformEvent-Class.html中的 performEvent
为什么这些库作者选择 s 为假?
【问题讨论】: