@@ -183,72 +183,6 @@ class FreeTSuite extends CatsSuite {
183183 }
184184 }
185185
186- sealed trait Test1Algebra [A ]
187-
188- case class Test1 [A ](value : Int , f : Int => A ) extends Test1Algebra [A ]
189-
190- def test1 [A ](value : Int , f : Int => A ): Test1Algebra [A ] = Test1 (value, f)
191-
192- object Test1Algebra {
193- implicit def test1AlgebraAFunctor : Functor [Test1Algebra ] =
194- new Functor [Test1Algebra ] {
195- def map [A , B ](a : Test1Algebra [A ])(f : A => B ): Test1Algebra [B ] = a match {
196- case Test1 (k, h) => Test1 (k, x => f(h(x)))
197- }
198- }
199-
200- implicit def test1AlgebraArbitrary [A ](implicit seqArb : Arbitrary [Int ], intAArb : Arbitrary [Int => A ]): Arbitrary [Test1Algebra [A ]] =
201- Arbitrary (for {s <- seqArb.arbitrary; f <- intAArb.arbitrary} yield Test1 (s, f))
202- }
203-
204- sealed trait Test2Algebra [A ]
205-
206- case class Test2 [A ](value : Int , f : Int => A ) extends Test2Algebra [A ]
207-
208- def test2 [A ](value : Int , f : Int => A ): Test2Algebra [A ] = Test2 (value, f)
209-
210- object Test2Algebra {
211- implicit def test2AlgebraAFunctor : Functor [Test2Algebra ] =
212- new Functor [Test2Algebra ] {
213- def map [A , B ](a : Test2Algebra [A ])(f : A => B ): Test2Algebra [B ] = a match {
214- case Test2 (k, h) => Test2 (k, x => f(h(x)))
215- }
216- }
217-
218- implicit def test2AlgebraArbitrary [A ](implicit seqArb : Arbitrary [Int ], intAArb : Arbitrary [Int => A ]): Arbitrary [Test2Algebra [A ]] =
219- Arbitrary (for {s <- seqArb.arbitrary; f <- intAArb.arbitrary} yield Test2 (s, f))
220- }
221-
222- type T [A ] = EitherK [Test1Algebra , Test2Algebra , A ]
223-
224- object Test1Interpreter extends FunctionK [Test1Algebra ,Id ] {
225- override def apply [A ](fa : Test1Algebra [A ]): Id [A ] = fa match {
226- case Test1 (k, h) => h(k)
227- }
228- }
229-
230- object Test2Interpreter extends FunctionK [Test2Algebra ,Id ] {
231- override def apply [A ](fa : Test2Algebra [A ]): Id [A ] = fa match {
232- case Test2 (k, h) => h(k)
233- }
234- }
235-
236- val eitherKInterpreter : FunctionK [T ,Id ] = Test1Interpreter or Test2Interpreter
237-
238- test(" .liftInject" ) {
239- forAll { (x : Int , y : Int ) =>
240- def res [F [_]]
241- (implicit I0 : Test1Algebra :<: F ,
242- I1 : Test2Algebra :<: F ): FreeT [F , Id , Int ] = {
243- for {
244- a <- FreeT .liftInject[Id , F ](test1(x, identity))
245- b <- FreeT .liftInject[Id , F ](test2(y, identity))
246- } yield a + b
247- }
248- (res[T ] foldMap eitherKInterpreter) == (x + y) should === (true )
249- }
250- }
251-
252186 test(" == should not return true for unequal instances" ) {
253187 val a = FreeT .pure[List , Option , Int ](1 ).flatMap(x => FreeT .pure(2 ))
254188 val b = FreeT .pure[List , Option , Int ](3 ).flatMap(x => FreeT .pure(4 ))
0 commit comments