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

Add an empty for OptionT #935

Closed
DomBlack opened this issue Mar 16, 2016 · 4 comments
Closed

Add an empty for OptionT #935

DomBlack opened this issue Mar 16, 2016 · 4 comments

Comments

@DomBlack
Copy link

Currently OptionT has a pure method, but it can be useful to have a empty method on the object. At the moment we're simply using the apply to work around it;

def something(empty: Boolean): OptionT[Future, String] = {
  if (empty) OptionT(Future.success(None)) else OptionT.pure("Hi")
}

However empty would look cleaner and be easier to understand

def something(empty: Boolean): OptionT[Future, String] = {
  if (empty) OptionT.empty else OptionT.pure("Hi")
}
@ceedubs
Copy link
Contributor

ceedubs commented Mar 16, 2016

👍 sounds good to me.

It'd look something like this, right?

def empty[F[_]:Applicative, A]: OptionT[F, A]

@ceedubs
Copy link
Contributor

ceedubs commented Mar 16, 2016

I'm wondering if something like OptionT.none might be a better name. It might be a little counterintuitive to call empty[List, String] and get back a List that isn't actually empty (but instead contains a single None element). I'm also thinking of empty[NonemptyList, String].

@adelbertc
Copy link
Contributor

+1 for OptionT.none

MaxWorgan added a commit to MaxWorgan/cats that referenced this issue Mar 24, 2016
stew added a commit that referenced this issue Apr 1, 2016
Added OptionT.none, resolving #935
@mikejcurry
Copy link
Contributor

I think this should be closed now because of: #946

@fthomas fthomas closed this as completed Apr 2, 2016
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

5 participants