forked from zio/interop-cats
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix zio#94, add catz.core object with implicits that require only cat…
…s-core, not cats-effect - also update README.md
- Loading branch information
Showing
6 changed files
with
146 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
core-only-test/shared/src/test/scala/zio/interop/test/CoreSummonSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package zio.interop.test | ||
|
||
import cats.data.NonEmptyList | ||
import cats.{ Bifunctor, Monad, MonadError, SemigroupK } | ||
import zio._ | ||
import zio.interop.catz.core._ | ||
import zio.stream.interop.catz.core._ | ||
import zio.stream.{ Stream, ZStream } | ||
import zio.test.Assertion._ | ||
import zio.test.{ DefaultRunnableSpec, test, _ } | ||
|
||
object CoreSummonSpec | ||
extends DefaultRunnableSpec( | ||
suite("summons from catz.core work with only a cats-core dependency")( | ||
test("ZIO instances") { | ||
val monad = implicitly[Monad[UIO]] | ||
val monadError = implicitly[MonadError[Task, Throwable]] | ||
val semigroupK = implicitly[SemigroupK[IO[NonEmptyList[Unit], ?]]] | ||
val bifunctor = implicitly[Bifunctor[IO]] | ||
|
||
monad.map(ZIO.unit)(identity) | ||
monadError.map(ZIO.unit)(identity) | ||
semigroupK.combineK(ZIO.unit, ZIO.unit) | ||
bifunctor.leftMap(ZIO.fromOption(None))(identity) | ||
|
||
assert((), anything) | ||
}, | ||
test("ZManaged instances") { | ||
val monad = implicitly[Monad[ZManaged[Any, Nothing, ?]]] | ||
val monadError = implicitly[MonadError[Managed[Throwable, ?], Throwable]] | ||
val semigroupK = implicitly[SemigroupK[Managed[Nothing, ?]]] | ||
val bifunctor = implicitly[Bifunctor[Managed]] | ||
|
||
monad.map(ZManaged.unit)(identity) | ||
monadError.map(ZManaged.unit)(identity) | ||
semigroupK.combineK(ZManaged.unit, ZManaged.unit) | ||
bifunctor.leftMap(ZManaged.fail(()))(identity) | ||
|
||
assert((), anything) | ||
}, | ||
test("ZStream instances") { | ||
val monad = implicitly[Monad[ZStream[Any, Nothing, ?]]] | ||
val monadError = implicitly[MonadError[Stream[Throwable, ?], Throwable]] | ||
val semigroupK = implicitly[SemigroupK[Stream[Nothing, ?]]] | ||
val bifunctor = implicitly[Bifunctor[Stream]] | ||
|
||
monad.map(ZStream.unit)(identity) | ||
monadError.map(ZStream.unit)(identity) | ||
semigroupK.combineK(ZStream.unit, ZStream.unit) | ||
bifunctor.leftMap(ZStream.fail(()))(identity) | ||
|
||
assert((), anything) | ||
} | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters