Skip to content

Commit

Permalink
Merge pull request #577 from fthomas/topic/curried
Browse files Browse the repository at this point in the history
Rename *Aux helper classes to *Curried
  • Loading branch information
stew committed Oct 31, 2015
2 parents 3317f52 + e398ae8 commit 870a30d
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 FromOptionAux[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[_]]: FromOptionAux[F] = new FromOptionAux
def fromOption[F[_]]: FromOptionPartiallyApplied[F] = new FromOptionPartiallyApplied

class FromOptionAux[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]: FromTryCatchAux[T] = new FromTryCatchAux[T]
def fromTryCatch[T >: Null <: Throwable]: FromTryCatchPartiallyApplied[T] = new FromTryCatchPartiallyApplied[T]

final class FromTryCatchAux[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]: FromTryCatchAux[T] =
new FromTryCatchAux[T]
def fromTryCatch[T >: Null <: Throwable]: FromTryCatchPartiallyApplied[T] =
new FromTryCatchPartiallyApplied[T]

final class FromTryCatchAux[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 FromXorAux[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[_]]: FromXorAux[F] = new FromXorAux
final def fromXor[F[_]]: FromXorPartiallyApplied[F] = new FromXorPartiallyApplied

final class FromXorAux[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 870a30d

Please sign in to comment.