Skip to content

Add shared Kyo companion operations#1647

Open
hearnadam wants to merge 2 commits into
mainfrom
kyo-companion-ops
Open

Add shared Kyo companion operations#1647
hearnadam wants to merge 2 commits into
mainfrom
kyo-companion-ops

Conversation

@hearnadam

Copy link
Copy Markdown
Collaborator

Problem

Kyo collection/pure operations from the Kyo object are not available on the companion objects of all effects.

Solution

Add abstract class to support sharing these methods throughout other effects.

@fwbrasil

Copy link
Copy Markdown
Collaborator

why provide it in all effects? Sync and Async seem enough and intuitive

@hearnadam

Copy link
Copy Markdown
Collaborator Author

why provide it in all effects? Sync and Async seem enough and intuitive

It's just lift and unit for all effects.

@fwbrasil

Copy link
Copy Markdown
Collaborator

I don't see a good motive to add those methods to all effects. We typically prefer canonical APIs and avoid duplication. I think this can be an exception given the discoverability issue but we should limit the duplication. An idea:

// this can be in kyo.internal but public
class KyoOps[S] private[kyo]():
   def lift[A](v: A): A < S = ...
   def collectAll(v: Chunk[A < S]): Chunk[A] < S

// rename the Kyo companion to Pure in kyo-kernel
object Pure extends KyoOps[Any]

object Sync extends KyoOps[Sync]

The use would be more intuitive:

  • If only kyo-prelude is in the classpath, which isn't a common case, Pure can be used matching the no side effects restriction of the module
  • Most users will be using kyo-core and, given the patterns in similar libraries, they'll try to find these methods in the equivalent of IO, landing on Sync
  • The pairing of Sync and Async with a similar set of methods seems much more intuitive already and Pure would follow a similar naming

@hearnadam hearnadam force-pushed the kyo-companion-ops branch from e0400d2 to b7c3016 Compare May 28, 2026 01:17
@hearnadam hearnadam force-pushed the kyo-companion-ops branch from b7c3016 to fa37019 Compare May 28, 2026 01:23
opaque type Async <: (Sync & Async.Join) = Async.Join & Sync

object Async extends AsyncPlatformSpecific:
object Async extends KyoOps[Sync], AsyncPlatformSpecific:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we don't need it here. Async has separate collection APIs with similar naming

@fwbrasil fwbrasil marked this pull request as ready for review May 31, 2026 04:21
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