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

Push Sync/Async constraints to interpreter level #18

Closed
wants to merge 4 commits into from

Conversation

2chilled
Copy link
Collaborator

@2chilled 2chilled commented Nov 9, 2022

Hi @armanbilge,

I stumbled across your calico project and am really considering to use it in a real world project. As I favor writing tagless final code I noticed both calico and fs2-dom use Sync/Async constraints at DSL level. Unfortunately this hinders effect tracking capabilities, since these constraints are so expressive they represent kind of all effects thinkable, similar to using IO directly.

This PR aims to mitigate this by pushing these "rule them all" constraints to interpreter level. Let me know what you think about this pattern. If you like it I am happy to PR something similar to calico 😃

@armanbilge
Copy link
Owner

Thanks for your PR and your interest! I also very much prefer the tagless final style and pushing Sync/Async constraints to the boundary.

Please see this related issue:

I need to take a closer look at this PR. fs2-dom is largely inspired by the fs2-io module, except instead of wrapping I/O APIs (socket, files, etc.) it wraps browser APIs. So my original intention was to follow the design patterns used there.

@armanbilge
Copy link
Owner

@2chilled thanks, I thought about this a bit and I am having a little bit of trouble understanding how this makes a difference in practice. Sorry 😅

If you don't mind, do you maybe have small example? That shows the problems with the current design, and how this PR will help that? I think it would be helpful to put these changes into some context. Thanks!

@2chilled
Copy link
Collaborator Author

Yes, I'll integrate a local snapshot version of this branch into calico and rewrite your example there. Hope I'll find time for this in the evening.

@armanbilge
Copy link
Owner

Cool! You may want to look at my branch with some redesign for Calico 0.2.

Indeed, in the TodoMVC example based on that branch there are only a few places that Sync or Async is needed.

  1. https://github.com/armanbilge/calico/blob/c6acd5d6db77a0d4a6ed4d25d53b219ad1129b77/todo-mvc/src/main/scala/todomvc/TodoMvc.scala#L42
  2. https://github.com/armanbilge/calico/blob/c6acd5d6db77a0d4a6ed4d25d53b219ad1129b77/todo-mvc/src/main/scala/todomvc/TodoMvc.scala#L80
  3. https://github.com/armanbilge/calico/blob/c6acd5d6db77a0d4a6ed4d25d53b219ad1129b77/todo-mvc/src/main/scala/todomvc/TodoMvc.scala#L98

Everything else can already be written in tagless final style using only Concurrent. The blocker is the problem I describe in armanbilge/calico#3 (comment), which I don't think your PR addresses. Meanwhile it's not obvious to me why the changes here are necessary.

Looking forward to hearing your thoughts, thanks!

@armanbilge
Copy link
Owner

@2chilled I just pushed a tagless final version of the Todo MVC app in Calico. It is based on #20.

https://github.com/armanbilge/calico/blob/bec9b18aea64d3abb75a1798bb6a7b1e05c29ceb/todo-mvc/src/main/scala/todomvc/TodoMvc.scala

There is still some room for improvement, but I am confident it demonstrates that the tagless final pattern is viable. Please let me know what you think :)

@2chilled
Copy link
Collaborator Author

Hi @armanbilge,

sorry for late response, I'm quite busy these days. Hope I'll find time this weekend to look into your tagless TodoMvc.

Just to keep you on track regarding my side:

Started to integrate fs2-dom SNAPSHOT into calico main branch. I'm now at a point where it almost typechecks, although another rabbit hole popped up: Your Modifier typeclass instances still need Async capabilities. To fix this, next step would be to introduce a proper DomDsl. I think you had a similar idea #20 😄

I know it's quite a bit of work to write DomDsl, but I think it's the only way to stay Sync-less until main function. I'll have much more time to focus on this in second half of december, so maybe we can really get it done this year.

@armanbilge
Copy link
Owner

No problem at all, take your time. Thanks for the update :)

I know it's quite a bit of work to write DomDsl, but I think it's the only way to stay Sync-less until main function.

Haha, yes, that's why I avoided this issue until now 😄 I agree, it is a necessity. After making some progress on that issue I am feeling optimistic about it :) thanks for the encouragement!

@2chilled
Copy link
Collaborator Author

Closing this for now. If Dom API Wrapping works, this'll be at interpreter level anyway.

@2chilled 2chilled closed this Nov 14, 2022
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.

2 participants