Skip to content

Commit

Permalink
Use PartiallyApplied as suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
fthomas committed Oct 20, 2015
1 parent 13f1034 commit e398ae8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions core/src/main/scala/cats/data/OptionT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,18 @@ object OptionT extends OptionTInstances {
/**
* Transforms an `Option` into an `OptionT`, lifted into the specified `Applicative`.
*
* Note: The return type is a FromOptionCurried[F], which has an apply method on it, allowing
* you to call fromOption like this:
* Note: The return type is a FromOptionPartiallyApplied[F], which has an apply method
* on it, allowing you to call fromOption like this:
* {{{
* val t: Option[Int] = ...
* val x: OptionT[List, Int] = fromOption[List](t)
* }}}
*
* The reason for the indirection is to emulate currying type parameters.
*/
def fromOption[F[_]]: FromOptionCurried[F] = new FromOptionCurried
def fromOption[F[_]]: FromOptionPartiallyApplied[F] = new FromOptionPartiallyApplied

class FromOptionCurried[F[_]] private[OptionT] {
class FromOptionPartiallyApplied[F[_]] private[OptionT] {
def apply[A](value: Option[A])(implicit F: Applicative[F]): OptionT[F, A] =
OptionT(F.pure(value))
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/data/Validated.scala
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ trait ValidatedFunctions {
* val result: Validated[NumberFormatException, Int] = fromTryCatch[NumberFormatException] { "foo".toInt }
* }}}
*/
def fromTryCatch[T >: Null <: Throwable]: FromTryCatchCurried[T] = new FromTryCatchCurried[T]
def fromTryCatch[T >: Null <: Throwable]: FromTryCatchPartiallyApplied[T] = new FromTryCatchPartiallyApplied[T]

final class FromTryCatchCurried[T] private[ValidatedFunctions] {
final class FromTryCatchPartiallyApplied[T] private[ValidatedFunctions] {
def apply[A](f: => A)(implicit T: ClassTag[T]): Validated[T, A] = {
try {
valid(f)
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/scala/cats/data/Xor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ trait XorFunctions {
* val result: NumberFormatException Xor Int = fromTryCatch[NumberFormatException] { "foo".toInt }
* }}}
*/
def fromTryCatch[T >: Null <: Throwable]: FromTryCatchCurried[T] =
new FromTryCatchCurried[T]
def fromTryCatch[T >: Null <: Throwable]: FromTryCatchPartiallyApplied[T] =
new FromTryCatchPartiallyApplied[T]

final class FromTryCatchCurried[T] private[XorFunctions] {
final class FromTryCatchPartiallyApplied[T] private[XorFunctions] {
def apply[A](f: => A)(implicit T: ClassTag[T]): T Xor A =
try {
right(f)
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/scala/cats/data/XorT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,18 @@ trait XorTFunctions {

/** Transforms an `Xor` into an `XorT`, lifted into the specified `Applicative`.
*
* Note: The return type is a FromXorCurried[F], which has an apply method on it, allowing
* you to call fromXor like this:
* Note: The return type is a FromXorPartiallyApplied[F], which has an apply method
* on it, allowing you to call fromXor like this:
* {{{
* val t: Xor[String, Int] = ...
* val x: XorT[Option, String, Int] = fromXor[Option](t)
* }}}
*
* The reason for the indirection is to emulate currying type parameters.
*/
final def fromXor[F[_]]: FromXorCurried[F] = new FromXorCurried
final def fromXor[F[_]]: FromXorPartiallyApplied[F] = new FromXorPartiallyApplied

final class FromXorCurried[F[_]] private[XorTFunctions] {
final class FromXorPartiallyApplied[F[_]] private[XorTFunctions] {
def apply[E, A](xor: Xor[E, A])(implicit F: Applicative[F]): XorT[F, E, A] =
XorT(F.pure(xor))
}
Expand Down

0 comments on commit e398ae8

Please sign in to comment.