Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7039281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:46:42+00:00 2026-05-28T01:46:42+00:00

I’m learning reactive-banana and intending to use it in a server-side app. I have

  • 0

I’m learning reactive-banana and intending to use it in a server-side app. I have some background in RxJs, so I’m used to combining Events with different combinators there. So I started with simple event combinator examples. I tried to make a simple reactive-banana example that would combine two integer events into a sum event. I understand that to be able to combine values from different events, I have to make them into Behaviors first, the do the combination and finally make that into a new event. This is how I did it:

-- Behaviors from Events e1, e2
let b1 = stepper 0 e1 :: Behavior Int
let b2 = stepper 0 e2 :: Behavior Int

-- Sum Behavior
let sumB = (+) <$> b1 <*> b2
-- Back to Event
let sumE = sumB <@ (e1 `union` e2)

Full runnable example can be found in Gist 1594917.

The problem here is that while the sumE event is correctly triggered when a new value appears in one of the events (e1, e2), it contains a stale value. This is apparently due to how stepper works (the value of the behavior changes “slightly after” the event occurrences). I tried replacing Behavior with Discrete, with the same result.

Is there a simple way to make this kind of event combinators work correctly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:46:43+00:00Added an answer on May 28, 2026 at 1:46 am

    Your diagnosis is exactly correct. Here are two options: you can work back to an Event from Discrete via changes, or you can create accumulating events.

    Working back from Discrete is probably simpler (and is what I would recommend). Just do

    -- Discretes from Events e1, e2
    let d1 = stepperD 0 e1 :: Discrete Int
    let d2 = stepperD 0 e2 :: Discrete Int
    
    -- Sum Discrete
    let sumD = (+) <$> d1 <*> d2
    -- Back to Event
    let sumE = changes sumD
    

    Now sumE will always update when e1 or e2 changes.

    The alternative uses only Events, by converting incoming events into accumulating functions. It sounds complex, but the code is fairly simple.

    --convert each input into an accumulating tuple
    let e1' = (\l (_,r) -> (l,r)) <$> e1
    let e2' = (\r (l,_) -> (l,r)) <$> e2
    
    let sumE = uncurry (+) <$> accumE (0,0) (e1' `union` e2')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.