Skip to content

Instantly share code, notes, and snippets.

View AdrianRaFo's full-sized avatar
🐕

Adrian Ramirez Fornell AdrianRaFo

🐕
  • Spain
  • 12:18 (UTC +02:00)
View GitHub Profile
@ChristopherDavenport
ChristopherDavenport / FakeIO.scala
Last active February 5, 2021 15:44
Simple FakeIO without stack-safety.
import cats.effect._
// import cats._
import cats.syntax.all._
import scala.concurrent.duration._
trait FakeIO[A]{
def unsafeRunAsync(f: Either[Throwable, A] => Unit): Unit
}
object FakeIO {
def delay[A](thunk: => A): FakeIO[A] = Async{cb: (Either[Throwable, A]=> Unit) => cb(Either.catchNonFatal(thunk))}
def async[A](f: (Either[Throwable, A] => Unit) => Unit): FakeIO[A] = Async{cb =>