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

Please add Yield() for OptionCE #101

Closed
AntyaDev opened this issue Oct 11, 2020 · 5 comments
Closed

Please add Yield() for OptionCE #101

AntyaDev opened this issue Oct 11, 2020 · 5 comments

Comments

@AntyaDev
Copy link

No description provided.

@TheAngryByrd
Copy link
Collaborator

Could you elaborate?

@AntyaDev
Copy link
Author

Hi @TheAngryByrd
Your implementation of option {} doesn't support yield operator
https://github.com/demystifyfp/FsToolkit.ErrorHandling/blob/master/src/FsToolkit.ErrorHandling/OptionCE.fs

member this.Yield(x) =

@TheAngryByrd
Copy link
Collaborator

Ok but why would this need to be implemented? And how?

@AntyaDev
Copy link
Author

Sorry, that didn't put a context.
If for example, I want to use

option {
for in do
yield item // this will be a compile error
}

I faced with this limitation recently and needed to switch from using CE.

@TheAngryByrd
Copy link
Collaborator

TheAngryByrd commented Oct 13, 2020

Option isn't for dealing with lists so I'm unsure if this is the computation expression you need in that scenario.

"More generally, of course, yield should be used for sequence/enumeration semantics, while return is normally used once per expression." - https://fsharpforfunandprofit.com/posts/computation-expressions-builder-part1/#introducing-yield

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