All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.Crawler.scala Maven / Gradle / Ivy

The newest version!
package masterleagueapi
package net

import fs2.Stream
import scala.language.higherKinds

object Crawler {

  def crawl[F[_], A, B](a: A, a2b: A => Stream[F, B], b2a: B => Stream[F, A], sleep: => Stream[F, Unit]): Stream[F, B] = {
    def rec(as: Stream[F, A]): Stream[F, B] =
      as.flatMap { a =>
        a2b(a).flatMap { b =>
          Stream.emit(b) ++ (sleep >> rec(b2a(b)))
        }
      }
    rec(Stream(a))
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy