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

Simpler effect representations creation #1

Open
ENvironmentSet opened this issue Aug 7, 2023 · 2 comments
Open

Simpler effect representations creation #1

ENvironmentSet opened this issue Aug 7, 2023 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@ENvironmentSet
Copy link
Owner

currently, effect representations are created like following:

interface IO extends Spec<'IO'> {
  read(): string
  write(text: string): void
}
const IO = createEffect<IO>('IO')

Here, name of effect is repeated 5 times. this makes look of API verbose and makes users be tired of writing name of effects.
Using interface, adding discrimination tag to spec type, having effect representation in variable, mentioning name of spec when creating effect representation seems to be inevitable. But giving name of effect we want to create as string literal seems to be avoidable and I really hope so. let's find a way.

@ENvironmentSet
Copy link
Owner Author

Here, I share my failed try. I tried to use symbols to dynamically -- and the way user don't notice -- generate identifier of effect representation but found this kind of work would make handler API verbose.

@ENvironmentSet
Copy link
Owner Author

Update: now we define effects like blow

type IO = Effect<'IO', {
  read(): string
  write(text: string): void
}>
const IO = createPrimitives<IO>('IO')

It's better but still have annoying repeat of effect name

@ENvironmentSet ENvironmentSet added the help wanted Extra attention is needed label Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant