Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions core/src/main/scala/cats/data/OptionT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ package data
*
* For more information, see the [[http://typelevel.org/cats/datatypes/optiont.html documentation]].
*/
/**
* OptionT is a wrapper for computations of type F[Option[A]].
*
* Example:
* {{{
* import cats.data.OptionT
* import cats.implicits._
*
* val result = OptionT(List(Option(1), None, Option(3)))
* result.map(_ + 1)
* // res0: cats.data.OptionT[List, Int] = OptionT(List(Some(2), None, Some(4)))
* }}}
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a ScalaDoc for OptionT already right above this one. If the goal is to add an example, then it makes sense to simply add the example section to the above ScalaDoc, rather than creating a whole new ScalaDoc itself.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! I’ve merged the example into the existing ScalaDoc as suggested.
Please let me know if any further adjustments are needed.


final case class OptionT[F[_], A](value: F[Option[A]]) {

def fold[B](default: => B)(f: A => B)(implicit F: Functor[F]): F[B] =
Expand Down