How to implement reactive-banana behaviors that recursively depend on themself?

。_饼干妹妹 提交于 2019-12-04 11:27:26
Heinrich Apfelmus

The exception is correct, you are defining a behavior directly in terms of itself.

alternater .. active = (.. <$> active <*> .. , ..)
ui b = do
    let (behavior, ..) = alternater .. (.. <$> b)
    return $ .. <*> behavior

... mfix ui

This code means that the current value of the result behavior in ui would depend on itself in a circular way.

Recursion always needs a little delay to be well-defined. The most convenient way to do that is to use mutual recursion between an event and a behavior built with stepper or accumB. See also this answer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!