我正在尝试使用 Yampa 编写一个简单的 FRP 示例,而不是等待 2 秒(如这里:https ://wiki.haskell.org/Yampa/reactimate )将在一定范围内等待随机时间。我尝试了多种不同的方法来以某种方式将 randomRIO 函数放入信号函数中,但无法真正掌握我应该做什么。我的意图是像这样替换 twoSecondsPassed 函数:
randomTimePassed :: SF () Bool
randomTimePassed = time >>> arr (\x -> x < randomRIO (0, 10))
但这似乎并没有因为类型不匹配而起作用。编译器输出:
* Couldn't match type `m0 a0' with `Double'
Expected: SF Time Bool
Actual: SF (m0 a0) Bool
* In the second argument of `(>>>)', namely
`arr (\ x -> x < randomRIO (0, 10))'
In the expression: time >>> arr (\ x -> x < randomRIO (0, 10))
In an equation for `randomTimePassed':
randomTimePassed = time >>> arr (\ x -> x < randomRIO (0, 10))
任何指向正确方向的指针都将不胜感激,因为我对 Yampa 很陌生,似乎找不到合适的文档来帮助我。