score:1

Accepted answer

So I've managed to transform the type by using liftM[OptionT].

So my callFfmpeg function can become:

def callFfmpeg(command: String): IO[Stream[String]] = IO {
    Process(command).lines_!
}

and my getStream function now becomes:

def getStream(fileName: String): OptionT[IO, Stream[String]] = {
    val optionalCommand: OptionT[IO, String] = findFfmpeg map {
        getCommand(_, fileName)
    }
    optionalCommand >>= {
        command => callFfmpeg(command).liftM[OptionT]
    }
}

This allows the conversion from IO[Stream[String]] to IO[Option[Stream[String]]] which is what I'm after.


Related Query

More Query from same tag