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

Standalone optic API #17

Open
mrjackdavis opened this issue Jun 21, 2024 · 1 comment
Open

Standalone optic API #17

mrjackdavis opened this issue Jun 21, 2024 · 1 comment

Comments

@mrjackdavis
Copy link

optic-ts contains a standalone api which looks a bit more like this

O.compose(
  'foo',
  O.optional,
  O.when((value: number) => value > 42)
)

I've come across instances where this API is preferable, especially if I'm reusing complex optics

e.g.

const myComplexOptic = O.compose(
  'foo',
  O.optional,
  O.guard((obj:{type:string}) => obj.type === 'bar')
)

const bazAtom = focusAtom(dataAtom,O.compose(myComplexOptic,'baz'));
const quxAtom = focusAtom(dataAtom,O.compose(myComplexOptic,'qux'));

This might also contribute to solving such issues as #15 without introducing new concepts

I think this would be worth implementing

@dai-shi
Copy link
Member

dai-shi commented Jun 21, 2024

Would you be interested in implementing it?
I think we should create a completely new function.

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

No branches or pull requests

2 participants