Skip to content

Commit

Permalink
Merge pull request #171 from alexandru/remove-andthen
Browse files Browse the repository at this point in the history
Remove AndThen, as StateT was fixed in Cats 1.1
  • Loading branch information
alexandru authored Mar 24, 2018
2 parents 70ff976 + 3a9bbd3 commit e46d4b9
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 222 deletions.
15 changes: 2 additions & 13 deletions core/shared/src/main/scala/cats/effect/Sync.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package effect

import simulacrum._
import cats.data._
import cats.effect.internals.{AndThen, NonFatal}
import cats.effect.internals.NonFatal
import cats.syntax.all._

/**
Expand Down Expand Up @@ -176,19 +176,8 @@ object Sync {
def raiseError[A](e: Throwable): StateT[F, S, A] =
StateT.liftF(F.raiseError(e))

override def map[A, B](fa: StateT[F, S, A])(f: A => B): StateT[F, S, B] =
IndexedStateT.applyF[F, S, S, B](F.map(fa.runF) { safsba =>
AndThen(safsba).andThen(fa => F.map(fa) { case (s, a) => (s, f(a)) })
})

def flatMap[A, B](fa: StateT[F, S, A])(f: A => StateT[F, S, B]): StateT[F, S, B] =
IndexedStateT.applyF[F, S, S, B](F.map(fa.runF) { safsba =>
AndThen(safsba).andThen { fsba =>
F.flatMap(fsba) { case (sb, a) =>
f(a).run(sb)
}
}
})
fa.flatMap(f)

// overwriting the pre-existing one, since flatMap is guaranteed stack-safe
def tailRecM[A, B](a: A)(f: A => StateT[F, S, Either[A, B]]): StateT[F, S, B] =
Expand Down
134 changes: 0 additions & 134 deletions core/shared/src/main/scala/cats/effect/internals/AndThen.scala

This file was deleted.

This file was deleted.

0 comments on commit e46d4b9

Please sign in to comment.