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

Applicative/Functor instance missing for OptionT #1107

Closed
tbrown1979 opened this issue Jun 9, 2016 · 4 comments
Closed

Applicative/Functor instance missing for OptionT #1107

tbrown1979 opened this issue Jun 9, 2016 · 4 comments

Comments

@tbrown1979
Copy link

Missing for when F doesn't have a Monad

@yilinwei
Copy link
Contributor

This is absolutely the case because a monad transfromer is not the same as a Nested.

See explanation here #1106.

@peterneyens
Copy link
Collaborator

It would still be possible to add something like scalaz.OptionT[F, ?].app, but it would give the same result as Nested[F, Option, ?].ap so that wouldn't be that useful probably.

I was wondering if we should add some sort of toNested on OptionT and XorT, in that way you could do OptionT(List(Some(1))).toNested.ap( ... ).
We could probably also use it to implement methods like OptionT.foldLeft for Foldable[OptionT[F, ?]] (which I just added in #1103, which also includes the Functor you mentioned)

def foldLeft[B](b: B)(f: (B, A) => B)(implicit F: Foldable[F]): B =
  toNested.foldLeft(value, b)(f)
  // F.foldLeft(value, b)((b, o) => optionInstance.foldLeft(o, b)(f))

@ceedubs
Copy link
Contributor

ceedubs commented Jun 18, 2016

@peterneyens I like your idea of toNested.

@ceedubs
Copy link
Contributor

ceedubs commented Sep 30, 2018

toNested was added in #1172, so I'm going to close this out.

@ceedubs ceedubs closed this as completed Sep 30, 2018
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

4 participants