Slide 90
Slide 90 text
1
2 def writer[F[_]: Applicative, A]: Trace[WriterT[F, Vector[A], ?]] =
3 Trace(a => WriterT.tell(a))
4
5 def stream[A](out: java.io.PrintStream, show: A => String) : Trace[IO, A] =
6 Trace(a => IO { out.println(show(a)) })
7
8 def out[A](show: A => String): Trace[IO, A] =
9 stream(Console.out)
10
11 def err[A](show: A => String): Trace[IO, A] =
12 stream(Console.err)
13
14 def noop[F[_]: Applicative, A]: Trace[F, A] =
15 Trace(_ => ().pure[F])
16
17 def hoistEither[F[_], A](t: Trace[F, A]): Trace[EitherT[F, _, A]] =
18 ???
19
20 def io[F[_], A](t: Trace[WriterT[F, Vector[A], ?], A]):Trace[IO, A] =
22 ???