Skip to content

Commit

Permalink
relax StreamT#trans constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Aug 2, 2015
1 parent 4e3ef04 commit fcc257a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/src/main/scala/scalaz/StreamT.scala
Expand Up @@ -26,8 +26,12 @@ sealed class StreamT[M[_], A](val step: M[StreamT.Step[A, StreamT[M, A]]]) {

def tailM(implicit M: Monad[M]): M[StreamT[M, A]] = M.map(uncons)(_.getOrElse(sys.error("tailM: empty StreamT"))._2)

def trans[N[_]](t: M ~> N)(implicit M: Monad[M], N: Functor[N]): StreamT[N, A] =
StreamTHoist.hoist(t).apply(this)
def trans[N[_]](t: M ~> N)(implicit M: Functor[M], N: Functor[N]): StreamT[N, A] =
StreamT(t(M.map(this.step)(
_( yieldd = (a, as) => Yield(a, as trans t)
, skip = as => Skip(as trans t)
, done = Done
))))

def filter(p: A => Boolean)(implicit m: Functor[M]): StreamT[M, A] = stepMap {
_( yieldd = (a, as) => if (p(a)) Yield(a, as filter p) else Skip(as filter p)
Expand Down

0 comments on commit fcc257a

Please sign in to comment.