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

Is Option or Result type have apply function? #145

Open
linitachi opened this issue Apr 19, 2023 · 5 comments
Open

Is Option or Result type have apply function? #145

linitachi opened this issue Apr 19, 2023 · 5 comments

Comments

@linitachi
Copy link

Is your feature request related to a problem? Please describe.
I want to using applicative in expression, like this example
https://github.com/dbrattli/OSlash/wiki/Functors,-Applicatives,-And-Monads-In-Pictures#applicatives

Describe the solution you'd like

a = Some(5)
b = lambda x: Some(x)
a.apply(b)

thanks!

@phi-friday
Copy link
Contributor

You can use a method bind.

import expression as ex

a = ex.Some(5)
b = lambda x: ex.Some(x)
a.bind(b)

@linitachi
Copy link
Author

Thanks for your reply!
I think bind is a flatmap and it's diffenrent from applicative,
if there are any applicative just like fp-ts apply?
https://gcanti.github.io/fp-ts/modules/Apply.ts.html

Thank you again for your reply!

@phi-friday
Copy link
Contributor

phi-friday commented Apr 24, 2023

Thanks for your reply! I think bind is a flatmap and it's diffenrent from applicative, if there are any applicative just like fp-ts apply? https://gcanti.github.io/fp-ts/modules/Apply.ts.html

Thank you again for your reply!

@linitachi I'm sorry
I left a comment without reading it properly.

@u3kkasha
Copy link
Contributor

u3kkasha commented Nov 15, 2023

@linitachi
Check this out : Effects

@u3kkasha
Copy link
Contributor

u3kkasha commented Jan 12, 2024

You can also use the member function called map2
>>> Some(8).map2(lambda x,y: x+y, Some(6))
Some 14

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

3 participants