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

Rename *Aux helper classes to *Curried #577

Merged
merged 2 commits into from
Oct 31, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
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
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