Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'coincidence' combinator #161

Open
mitchellwrosen opened this issue Sep 26, 2017 · 6 comments
Open

'coincidence' combinator #161

mitchellwrosen opened this issue Sep 26, 2017 · 6 comments

Comments

@mitchellwrosen
Copy link
Collaborator

Here's another combinator in reflex missing that's from reactive-banana:

coincidence :: Event (Event a) -> Event a
@ocharles
Copy link
Collaborator

Isn't this switchE, but without the monad enforcing that we don't leak?

@HeinrichApfelmus
Copy link
Owner

A semantic specification would be nice, so that we know what exactly, if anything, to implement. 😄

@mitchellwrosen
Copy link
Collaborator Author

Whoops :)

The returned event emits whenever the outer and inner events emit simultaneously.

@mitchellwrosen
Copy link
Collaborator Author

mitchellwrosen commented Feb 21, 2023

The semantics are

type Event a = [Maybe a] -- infinite

coincidence :: Event (Event a) -> Event a
coincidence (x0 : xs) =
  case x0 of
    Just (Just x : _) -> Just x : ys
    _ -> Nothing : ys
  where
    ys = coincidence (map (drop 1) xs)

@ocharles
Copy link
Collaborator

Presumably case x0 of Just (Nothing : _) -> Nothing : ys too?

@mitchellwrosen
Copy link
Collaborator Author

Yeah, whoops! Editing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants