Skip to content

Commit

Permalink
add some more documentation of Is methods
Browse files Browse the repository at this point in the history
  • Loading branch information
tel committed Jul 12, 2016
1 parent 8174c5c commit 1d3f3ed
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion core/src/main/scala/cats/evidence/Is.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,32 @@ abstract class Is[A, B] extends Serializable {
*/
def substitute[F[_]](fa: F[A]): F[B]

/**
* `Is` is transitive and therefore values of `Is` can be composed in a
* chain much like functions. See also `compose`.
*/
@inline final def andThen[C](next: B Is C): A Is C =
next.substitute[A Is ?](this)

/**
* `Is` is transitive and therefore values of `Is` can be composed in a
* chain much like functions. See also `andThen`.
*/
@inline final def compose[C](prev: C Is A): C Is B =
prev andThen this

@inline final def from: B Is A =
/**
* `Is` is symmetric and therefore can be flipped around. Flipping is its
* own inverse, so `x.flip.flip == x`.
*/
@inline final def flip: B Is A =
this.substitute[? Is A](Is.refl)

/**
* Sometimes for more complex substitutions it helps the typechecker to
* wrap one layer of `F[_]` context around the types you're equating
* before substitution.
*/
@inline final def lift[F[_]]: F[A] Is F[B] =
substitute[λ[α => F[A] Is F[α]]](Is.refl)

Expand Down

0 comments on commit 1d3f3ed

Please sign in to comment.