Skip to content

Refactor FirstToFinish and LastToFinish instances#3850

Closed
coot wants to merge 2 commits intomainfrom
coot/monoidal-sync
Closed

Refactor FirstToFinish and LastToFinish instances#3850
coot wants to merge 2 commits intomainfrom
coot/monoidal-sync

Conversation

@coot
Copy link
Copy Markdown
Collaborator

@coot coot commented Jun 29, 2022

No description provided.

coot and others added 2 commits June 29, 2022 08:51
Deriving a semigroup instance via 'Alt' for 'IO' relies on 'IO'
'Alternative' instance, which is not what we want.  We want 'race`
semantics instead.

The drawback is that one needs to specify the
'Semigroup (FirstToFinish m a)' constraint, when 'm' is abstract, as in
the tests.


instance Semigroup (FirstToFinish IO a) where
FirstToFinish a <> FirstToFinish b = FirstToFinish $ either id id <$> race a b
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We can use similar approach to LastToFinish.

, MonadTime m
, MonadTimer m
, MonadMask m
, forall a stm. stm ~ STM m => Semigroup (FirstToFinish stm a)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Use a type alias for this constraint if possible.

@coot coot removed the networking label Dec 18, 2023
Copy link
Copy Markdown
Contributor

@bolt12 bolt12 left a comment

Choose a reason for hiding this comment

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

What's the difference between LastToFinish and LastToFinishM?

@coot
Copy link
Copy Markdown
Collaborator Author

coot commented Oct 25, 2024

The difference is explained here.

@coot coot closed this Mar 12, 2026
@coot coot deleted the coot/monoidal-sync branch March 12, 2026 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants