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

Add _Cons and _Snoc instances for (Dual s) (Dual t) a b #950

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Taneb
Copy link
Collaborator

@Taneb Taneb commented Dec 7, 2020

This allows treating a cons-list as a snoc-list in a reasonable way and vice versa

One use case for this is Dual [a] can be used as a snoc list in an efficient way, if a snoc list is more "semantically" correct.

This allows treating a cons-list as a snoc-list in a reasonable way and vice versa

One use case for this is Dual [a] can be used as a snoc list in an efficient way, if a snoc list is more "semantically" correct.
@RyanGlScott
Copy link
Collaborator

Is it commonplace to interpret Dual [a] as a snoc list? I'm accustomed to thinking of Dual in the "dual monoid" sense, but these instances seem to be giving Dual an additional meaning, in the sense that it treats Cons and Snoc as dual operations. Perhaps this is a sensible thing to do, but I can't recall having seen something like this before.

@Taneb
Copy link
Collaborator Author

Taneb commented Dec 7, 2020

I don't know if it's used often, but I reached for it today, thinking of its Monoid instance

@phadej
Copy link
Collaborator

phadej commented Dec 7, 2020

I think this is on edge of being too ad-hoc, and I'm not sure on which side. _Empty, _Cons, Monoid aren't "officially" related, but (I guess) are true for all instances (of Cons). If we had Singleton we could tie this all together formally, but otherwise it is a collection of names which accidentally make sense together.

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

Successfully merging this pull request may close these issues.

None yet

3 participants