diff options
author | zachdriver <zach@driver.xyz> | 2017-08-03 11:32:35 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-03 11:32:35 -0700 |
commit | 886415aa5f86e758d9a9aafa8f60128e3473311a (patch) | |
tree | f4074f36706322e1a5a95f165b69c354fde9160d /src/main/scala/xyz/driver/core | |
parent | f1328134ada77d1c21374f7cca953a376a9b27f9 (diff) | |
parent | c5620d091a06df039be92e8c3b6d95e226384292 (diff) | |
download | driver-core-886415aa5f86e758d9a9aafa8f60128e3473311a.tar.gz driver-core-886415aa5f86e758d9a9aafa8f60128e3473311a.tar.bz2 driver-core-886415aa5f86e758d9a9aafa8f60128e3473311a.zip |
Merge pull request #58 from drivergroup/zsmith/subflatMapv0.15.1
Add subflatMap to OptionT (stolen from cats)
Diffstat (limited to 'src/main/scala/xyz/driver/core')
-rw-r--r-- | src/main/scala/xyz/driver/core/core.scala | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/main/scala/xyz/driver/core/core.scala b/src/main/scala/xyz/driver/core/core.scala index 1babd91..4747574 100644 --- a/src/main/scala/xyz/driver/core/core.scala +++ b/src/main/scala/xyz/driver/core/core.scala @@ -32,6 +32,9 @@ package object core { def continueIgnoringNone: OptionT[H, Unit] = optionTValue.map(_ => ()).orElse(OptionT.some[H, Unit](())) + + def subflatMap[B](f: T => Option[B]): OptionT[H, B] = + OptionT.optionT[H](implicitly[Monad[H]].map(optionTValue.run)(_.flatMap(f))) } implicit class MonadicExtensions[H[_]: Monad, T](monadicValue: H[T]) { |