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

Implement widget updates #5

Merged
merged 2 commits into from
Feb 17, 2024
Merged

Implement widget updates #5

merged 2 commits into from
Feb 17, 2024

Conversation

postsolar
Copy link
Owner

@postsolar postsolar commented Feb 17, 2024

Closes #3

It works, but the API still need some polishing:

  let
    label /\ updateLabel = W.label'
      { label: asOneOf "abcdef"
      }

  void $ setInterval (Milliseconds 2000.0) do
    log "updating"
    updateLabel \w → w
      { label = U.toEither1 w.label # lmap reverse # either asOneOf asOneOf
      }

No way to bypass untagged union here, but we can add a bifunctorial wrapper to make it a bit nicer.

It works, but the API still need some polishing:

```purescript

  let
    label /\ updateLabel = W.label'
      { label: asOneOf "abcdef"
      }

  void $ setInterval (Milliseconds 2000.0) do
    log "updating"
    updateLabel \w → w
      -- no way to bypass untagged union here, but we can add a bifunctorial wrapper
      -- to make it a bit nicer
      { label = U.toEither1 w.label # lmap reverse # either asOneOf asOneOf
      }
```
@postsolar
Copy link
Owner Author

postsolar commented Feb 17, 2024

A newtype over OneOf a (Binding a) for a bifunctor instance is tricky to implement because it requires that a has a runtime type representation, but it does not show up in instance head. Approaching it from other angles leads to similar issues. Would probably be a lot better to provide a few shortcuts and leave it to the user to use optics here as they're a lot more flexible.

@postsolar postsolar marked this pull request as ready for review February 17, 2024 22:18
@postsolar postsolar changed the title [WIP] Implement widget updates Implement widget updates Feb 17, 2024
@postsolar postsolar merged commit c56cd74 into master Feb 17, 2024
1 check passed
@postsolar postsolar deleted the update-widget-props branch February 17, 2024 22:49
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.

Exposing widget properties
1 participant