frp

Collecting Observables to a List doesn't seem to emit the collection at once

别说谁变了你拦得住时间么 提交于 2019-12-04 11:47:13
问题 I'm using RxJava to essentially collect the list of individually emitted Observables and combine them into a list of Observables (essentially sort of the opposite of flatMap). Here's my code: // myEvent.findMemberships() returns an Observable<List<Membership>> myEvent.findMemberships() .flatMap(new Func1<List<Membership>, Observable<User>>() { @Override public Observable<User> call(List<Membership> memberships) { List<User> users = new ArrayList<User>(); for (Membership membership :

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

。_饼干妹妹 提交于 2019-12-04 11:27:26
I have a Behavior whose value I want to change based on the occurrence of an Event and the Behavior's current value. In the example below I have two counters that are updated based on whether a boolean behaviour is True or False. As it is this code crashes with a <<loop>> exception, but I'm unsure how to restructure it to work or how else to approach this problem. {-# LANGUAGE ScopedTypeVariables #-} import Reactive.Banana import Reactive.Banana.Frameworks import Control.Arrow import Control.Concurrent import Control.Monad import Control.Monad.Fix counter :: Bool -> Event t Int -> Behavior t

How to derive FRP from Directed Acyclic Graphs?

帅比萌擦擦* 提交于 2019-12-04 10:36:39
问题 I am currently researching for my next project. This is in a pre-planning phase so this question is just to get an overview on existing technology. Setup I have a directed acyclic graph (DAG) with multiple inputs and output, think artificial neuronal network for now: The common way to process such a structure is to process the whole network on every (time-)step. I believe that is the method used by frp libraries such as netwire. Now I am in the fortunate position that I have a stream of

Fighting with FRP

淺唱寂寞╮ 提交于 2019-12-04 07:50:34
I've read about FRP and was very excited. It looks great, so you can write more high-level code, and everything is more composable, and etc. Then I've tried to rewrite my own little game with a few hundreds sloc from plain js to Bacon. And I found that instead of writing high-level logic-only code, I actually beating with Bacon.js and its adherence to principles. I run into some headache that mostly interfere clean code .take(1) Instead of getting value, I should create ugly constructions. Circular dependencies Sometimes they should be by logic. But implementing it in FRP is scary Active state

Convert from arrow notation

半城伤御伤魂 提交于 2019-12-04 06:11:50
I'm still trying to get a hang of the parallels between arrow notation and the semantics of the Arrow typeclasses defined in Haskell. In particular, this question seems to have a very canonical example of a small counter written with arrow notation: counter :: ArrowCircuit a => a Bool Int counter = proc reset -> do rec output <- returnA -< if reset then 0 else next next <- delay 0 -< output+1 returnA -< output Can someone show me how to convert this back into Haskell2010 without arrow notation? {- | +---------+ >Bool>--------------> | | >------------------>Int> +---------+ | arr f | /---->

Getting input into Netwire programs

人走茶凉 提交于 2019-12-04 01:15:43
I'm getting started with Netwire version 5. I have no problem writing all the wires I want to transform my inputs into my outputs. Now the time has come to write the IO wrapper to tie in my real-world inputs, and I am a bit confused. Am I supposed to create a custom session type for the s parameter of Wire s e m a b and embed my sensor values in there? If so, I have these questions: What's up with the Monoid s context of class (Monoid s, Real t) => HasTime t s | s -> t ? What is it used for? I was thinking of tacking on a Map String Double with my sensor readings, but how should my monoid

Confused about diagrams of Yampa switches

若如初见. 提交于 2019-12-03 20:06:35
There is some diagrams of Yampa switches at: http://www.haskell.org/haskellwiki/Yampa/switch http://www.haskell.org/haskellwiki/Yampa/rSwitch http://www.haskell.org/haskellwiki/Yampa/kSwitch (and so on). I've found that the switch , the only one diagram with description, is the easiest one to get understand. The others seems hard to follow the similar symbols to read the diagrams. For example, to try to read the rSwitch with the symbols used in the switch may be: Be a recursive SF which is always fed a signal of type 'in' and returns a signal of type 'out'. Start with an initial SF of the same

Retrying an asynchronous operation using ReactiveCocoa

孤人 提交于 2019-12-03 19:32:57
问题 I'm using ReactiveCocoa signals to represent calls to RESTful backend in our system. Each RESTful invocation should receive a token as one of the parameters. The token itself is received from authentication API call. All works fine and we're now introduced token expiration, so the backend access class may need to reauthorize itself if the API call fails with HTTP code 403. I want to make this operation completely transparent for the callers, this is the best I came up with: - (RACSignal *

Testing in reactive-banana

試著忘記壹切 提交于 2019-12-03 14:50:00
Is there a way to unit test networks created in reactive banana? Say I've built up some network with some input events - is it possible to verify that events have produced some output stream/behaviours have some value after some number of input events. Does it even make sense to do this? I noticed there are various interpret* functions but couldn't seem to work out how to use them. There's also the Model module which looks ideal for testing but has completely different types to the real implementation. When you say "unit test," I'm imagining something like QuickCheck , where you inject a

Higher order FRP with React - why is it not happening?

♀尐吖头ヾ 提交于 2019-12-03 11:40:37
问题 Redux is a kind of first order FRP, like Elm used to be. It seems however that higher order FRP is not really being used together with react. Why is first order FRP useful with React and higher order not so useful ? Maybe higher-order-ism is not needed with React ? So in return one can keep the time travelling debugger ? In other words: React is a function that takes a state and gives back a view. FRP is a way to declare and execute a state machine. These are orthogonal concerns, so why not