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.
Source: stackoverflow.com
Related Query
- How to I convert between monad stacks with transformers in scalaz 7
- How to avoid stair-stepping with Monad Transformers in scala?
- How to compose monad transformers in scalaz
- How to convert between to case classes with `mostly the same` fields using Scala Shapeless
- How to convert an Int to a String of a given length with leading zeros to align?
- How can I convert Scala Map to Java Map with scala.Float to java.Float k/v conversion
- How do I disambiguate in Scala between methods with vararg and without
- How to convert immutable Seq to mutable seq with until loop
- How to compose function to applicatives with scalaz
- How to convert a string column with milliseconds to a timestamp with milliseconds in Spark 2.1 using Scala?
- How to use Scalaz 7's EitherT with liftM
- Reader Monad with Scalaz
- How to use the free monad with Future[M[_]]
- How to convert Iterator to scalaz stream?
- How to handle nested structure when traversing with state monad
- How to implement a short-circuit with IO monad in Scala
- Apache Spark: How do I convert a Spark DataFrame to a RDD with type RDD[(Type1,Type2, ...)]?
- How can I convert scala.xml.Elem to something compatible with the javax.xml APIs?
- How to convert a `NonEmptyList[Either[Error, User]]` to `Either[Error, NonEmptyList[User]]` with cats?
- How can I combine two scalaz streams with a predicate selector?
- How to convert RDD of custom Java class objects to a DataFrame with toDF()?
- How to write for comprehension in cats with IO monad
- How to compare a string with another where the one has space in between
- How to convert list to mutable map with pre processing in Scala?
- How to convert list of integers to a map with frequency per bin?
- Wrapping a Monad into a parser - do I need Monad Transformers and how to do it?
- how do i convert json with mixed type values to json with scala and json spray
- How to help Scalaz with type inference and 2 type parameters
- how to convert JString to Int with json4s
- How to convert a Array of Map object with values to a single Map
More Query from same tag
- NoClassDefFoundError for Play app with sbt using Eclipse
- how to convert nested json file into csv in scala
- Akka http trust all certs
- ERROR SparkContext: Error initializing SparkContext.. IntelliJ and Scala
- Add items to Future[List] inside recursion
- Execute Future.sequence with custom ExecutionContext
- How to obtain java.lang.reflect.Type from a Scala type?
- Looking for an element in the array scala
- winutils binary for Spark 1.4.1 in IntelliJ Idea 14.1
- Strange generic method behaviour
- Cannot resolve symbol NotNull with Slick 3.1.1
- Spark Structured Streaming cannot read from kafka inside docker
- Mutating a HashMap concurrently in Scala without Actors
- Convert sphere function to tail recursive function
- Convert List<Enum> into Seq[(String,String)]
- regex to replace characters in a string
- Unable to get Simple Name for Types Inside Nested Object Hierarchy
- Kafka MirrorMaker's consumer not fetching all messages from topics
- Scala - Why can't infer List of Seq for a list containing Vector and List?
- How to load newer version of json4s in Spark 2.1 executor?
- Using typeclasses wtih multiple type parameters
- scala future null pointer match error
- Scala Futures callback hell
- withColumn function in scala not adding a contstant value to column
- Unbound Wildcard Type
- Read JSON data from Blob where the files are stored inside date folders which auto increments everyday
- Unable to properly handle errors
- SparkStreaming/Scala/Twitter java.lang.NoSuchMethodError: twitter4j.TwitterStream.addListener(Ltwitter4j/StreamListener;)V
- Requesting an advice on big data validation
- How to examine implicit/rich conversions and implemented traits in the REPL