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

Change free applicative implementation to Ørjan's #15

Closed
UnkindPartition opened this issue Apr 1, 2013 · 3 comments
Closed

Change free applicative implementation to Ørjan's #15

UnkindPartition opened this issue Apr 1, 2013 · 3 comments

Comments

@UnkindPartition
Copy link

Ørjan's version stores values in a more natural order.

Please see the code and detailed description in my article.

@ekmett
Copy link
Owner

ekmett commented Apr 1, 2013

The main reason to consider favoring Twan's approach and the reason that I did so originally was that it gave you immedate access to the 'next' instruction at the root. If you left associate to Ørjan's version then you have to walk under /n/ Ap nodes to figure out what you're doing next. With Twan's you can see the 'next' instruction in /O(1)/ when walking left to right, which is most common. Of course, not everything works left to right like a parser or pretty printer, but a lot of things do

@UnkindPartition
Copy link
Author

Sounds fair. I'll update the article with this consideration.

I'm not too concerned about which implementation ends up in the free package — it's not a big deal to copy&paste those 15 lines when I need them.

@roconnor
Copy link

roconnor commented Apr 2, 2013

Based on my work on Kleene Stores, I eventually settled on the Applicative instance using flip as the "forward" version and the one with compose was "backwards". This is in part corroborated by the fact that using the compose version with the Backwards applicative is not as lazy as using the flip version directly. Assuming the Free Applicative is analogous to Kleene Store, then I'd argue that Twan's version is the natural direction.

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

3 participants