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

Weaken constraint from Monoid to Semigroup #26

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

leifmetcalf
Copy link

@leifmetcalf leifmetcalf commented Jun 17, 2020

This breaks a bunch of stuff:

  • startUpdateNetwork and startUpdateNetworkWithValue now return
    'Maybe a' instead of 'a' if no change has happened since the last
    sample.

  • 'Update' no longer has an Applicative instance. An Applicative
    instance isn't possible (nicely) with only a Semigroup constraint.

I've also removed IOMonoid since, as of base 4.9.0.0, IO has an
identical Monoid instance.

@maoe
Copy link
Member

maoe commented Jun 23, 2020

Can we switch back to Travis or GitHub Actions? We don't use GitLab for this project.

@pacak
Copy link
Member

pacak commented Jun 23, 2020

Why is this change needed? Why do we need enummaps?

@leifmetcalf
Copy link
Author

Can we switch back to Travis or GitHub Actions? We don't use GitLab for this project.

I don't have the permissions to setup Github actions (or Gitlab CI for that matter). I can add a travis config.

@maoe
Copy link
Member

maoe commented Jun 23, 2020

I don't have the permissions to setup Github actions (or Gitlab CI for that matter).

I think it's enabled by default unless explicitly disabled. If you use Travis please use haskell-ci to generate a config. I'm fine either of GitHub Actions or Travis.

This breaks a bunch of stuff:

    * startUpdateNetwork and startUpdateNetworkWithValue now return
      'Maybe a' instead of 'a' if no change has happened since the last
      sample.

    * 'Update' no longer has an Applicative instance. An Applicative
      instance isn't possible (nicely) with only a Semigroup constraint.

I've also removed IOMonoid since, as of base 4.9.0.0, IO has an
identical Monoid instance.
@leifmetcalf leifmetcalf force-pushed the master branch 6 times, most recently from d6f7001 to 59ca757 Compare June 23, 2020 05:07
@leifmetcalf
Copy link
Author

leifmetcalf commented Jun 23, 2020

I think it's enabled by default unless explicitly disabled. If you use Travis please use haskell-ci to generate a config. I'm fine either of GitHub Actions or Travis.

I've added an actions workflow. You can see a run here: https://github.com/leifmetcalf/euphoria/actions/runs/144463831

FRP/Euphoria/Update.hs Show resolved Hide resolved
.github/workflows/ci.yaml Outdated Show resolved Hide resolved
.github/workflows/ci.yaml Outdated Show resolved Hide resolved
@leifmetcalf leifmetcalf force-pushed the master branch 2 times, most recently from df3da17 to 3d67396 Compare June 23, 2020 05:18
Copy link
Member

@maoe maoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not sure why the Semigroup constraint is better. Could you elaborate a bit?

euphoria.cabal Show resolved Hide resolved
euphoria.cabal Outdated Show resolved Hide resolved
euphoria.cabal Outdated Show resolved Hide resolved
euphoria.cabal Show resolved Hide resolved
euphoria.cabal Show resolved Hide resolved
.github/workflows/ci.yaml Outdated Show resolved Hide resolved
@leifmetcalf leifmetcalf force-pushed the master branch 2 times, most recently from b06b1b5 to e8f99a8 Compare June 23, 2020 05:38
@leifmetcalf
Copy link
Author

leifmetcalf commented Jun 23, 2020

I'm still not sure why the Semigroup constraint is better. Could you elaborate a bit?

You cannot implement eventToUpdate :: Event a -> Update a with a Monoid constraint (what would sampling eventToUpdate mempty return?). Instead, we currently implement eventToUpdate :: Event a -> Update (Just a), and we handle the handle the Nothing case (i.e. the case where no event has occurred since the last sample) with code like this:

g :: Maybe Text -> IO ()
g Nothing = pure ()
g (Just s) = putStrLn s

We can avoid this by changing the constraint in Update from Monoid to Semigroup. Instead of handling the no-event case in the FRP code, we handle it in the sampling code:

startUpdateNetwork :: Update a -> IO (IO (Maybe a) {- sample -}, IO () {- step -})

@leifmetcalf
Copy link
Author

@leifmetcalf
Copy link
Author

@maoe Why would we want an Applicative instance for update?

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.

3 participants