Skip to content

Commit

Permalink
Add IndexedState alias (typelevel#2686)
Browse files Browse the repository at this point in the history
  • Loading branch information
Valy Dia committed Jan 10, 2019
1 parent d88b3c4 commit ebacd83
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/src/main/scala/cats/data/IndexedStateT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,12 @@ sealed abstract private[data] class IndexedStateTInstances4 {
new IndexedStateTStrong[F, V] { implicit def F = F0 }
}

abstract private[data] class IndexedStateFunctions {

def apply[S1, S2, A](f: S1 => (S2, A)): IndexedState[S1, S2, A] =
IndexedStateT.applyF(Now((s: S1) => Now(f(s))))
}

// To workaround SI-7139 `object State` needs to be defined inside the package object
// together with the type alias.
abstract private[data] class StateFunctions {
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/scala/cats/data/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ package object data {
def tell[L](l: L): Writer[L, Unit] = WriterT.tell(l)
}

type IndexedState[S1, S2, A] = IndexedStateT[Eval, S1, S2, A]
object IndexedState extends IndexedStateFunctions

/**
* `StateT[F, S, A]` is similar to `Kleisli[F, S, A]` in that it takes an `S`
* argument and produces an `A` value wrapped in `F`. However, it also produces
Expand Down

0 comments on commit ebacd83

Please sign in to comment.