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

Fanning sums #316

Closed
treeowl opened this issue Jun 25, 2019 · 9 comments
Closed

Fanning sums #316

treeowl opened this issue Jun 25, 2019 · 9 comments

Comments

@treeowl
Copy link
Contributor

treeowl commented Jun 25, 2019

I may not understand this properly, but at first glance it seems that fanEither should generalize to something like

fanSum
  :: (GCompare tag, GEnum tag)
  => Event t (DSum tag f) -> DMap tag (Compose (Event t) f)

where GEnum offers a way to enumerate all the tags. (Possible methods: enumTags :: [DSum tag Proxy], enumTagsMap :: DMap tag Proxy).

Simplifying to Identity, that's

fanSumId
  :: (GCompare tag, GEnum tag)
  => Event t (DSum tag Identity) -> DMap tag (Event t)

The idea is that if we have a stream of messages of various types, we should be able to separate it into multiple streams, each of which contains messages of only one type. The big question is whether there's a way to implement this efficiently. I don't have a clue myself.

Note: I've opened an issue for dependent-sum suggesting such a class.

@ryantrinkle
Copy link
Member

ryantrinkle commented Jun 25, 2019 via email

@3noch
Copy link
Member

3noch commented Jun 25, 2019

Have you looked at factorEvent?

@treeowl
Copy link
Contributor Author

treeowl commented Jun 25, 2019

@ryantrinkle Ah, I think I see what you mean. Yes, that's probably sufficient, but it seems like overkill. I can turn each DSum into a singleton DMap and use fan with that, but it seems clearer (and at least a bit more efficient) to avoid that.

@treeowl
Copy link
Contributor Author

treeowl commented Jun 25, 2019

@3noch factorEvent doesn't look likely, since it's all about paying attention to when the key changes and I don't care about that.

@ryantrinkle
Copy link
Member

ryantrinkle commented Jun 25, 2019 via email

@treeowl
Copy link
Contributor Author

treeowl commented Jun 25, 2019

If you don't think it matters, then that's fine. It would at least be nice to offer it as a function if not a method, since it takes a bit of mental gymnastics to see that fan does the job.

@treeowl
Copy link
Contributor Author

treeowl commented Jun 25, 2019

Oh, but there is still the matter of type .... Why is fan only for Identity?

@ryantrinkle
Copy link
Member

ryantrinkle commented Jun 25, 2019 via email

@oliver-batchelor
Copy link
Collaborator

Implemented as PR #318

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

No branches or pull requests

4 participants