Skip to content

Commit fe49b37

Browse files
committed
Checkpoint of despair
1 parent 1433d62 commit fe49b37

File tree

7 files changed

+83
-27
lines changed

7 files changed

+83
-27
lines changed

build.sbt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ lazy val commonSettings = Seq(
4242

4343
"org.scalacheck" %% "scalacheck" % "1.13.5" % "test"),
4444

45+
libraryDependencies ++= Seq(
46+
"org.typelevel" %% "macro-compat" % "1.1.1",
47+
"org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided",
48+
"org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided",
49+
compilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)),
50+
4551
addCompilerPlugin("org.spire-math" % "kind-projector" % "0.9.3" cross CrossVersion.binary),
4652

4753
// Adapted from Rob Norris' post at https://tpolecat.github.io/2014/04/11/scalac-flags.html
@@ -152,6 +158,8 @@ lazy val core = crossProject
152158
"org.typelevel" %%% "cats-free" % CatsVersion,
153159
"org.scalaz" %%% "scalaz-core" % ScalazVersion,
154160

161+
"com.chuusai" %%% "shapeless" % "2.3.2",
162+
155163
"org.typelevel" %% "discipline" % "0.7.3" % "test",
156164
"org.typelevel" %%% "cats-laws" % CatsVersion % "test"))
157165
.enablePlugins(AutomateHeaderPlugin)

core/src/main/scala/shims/conversions/bi.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ trait BifoldableConversions extends MonoidConversions {
6161
private[conversions] trait BifoldableShimC2S[F[_, _]] extends scalaz.Bifoldable[F] with Synthetic {
6262
val F: cats.Bifoldable[F]
6363

64-
override def bifoldMap[A, B, M: scalaz.Monoid](fa: F[A, B])(f: A => M)(g: B => M): M =
65-
F.bifoldMap(fa)(f, g)
64+
override def bifoldMap[A, B, M: scalaz.Monoid](fa: F[A, B])(f: A => M)(g: B => M): M = ???
65+
// F.bifoldMap(fa)(f, g)
6666

67-
override def bifoldRight[A, B, C](fa: F[A, B], z: => C)(f: (A, => C) => C)(g: (B, => C) => C): C =
68-
F.bifoldRight(fa, Eval.always(z))((a, c) => c.map(f(a, _)), (b, c) => c.map(g(b, _))).value
67+
override def bifoldRight[A, B, C](fa: F[A, B], z: => C)(f: (A, => C) => C)(g: (B, => C) => C): C = ???
68+
// F.bifoldRight(fa, Eval.always(z))((a, c) => c.map(f(a, _)), (b, c) => c.map(g(b, _))).value
6969
}
7070

7171
implicit def bifoldableToScalaz[F[_, _], T](implicit FC: Capture[cats.Bifoldable[F], T], ev: T </< Synthetic): scalaz.Bifoldable[F] with Synthetic =
@@ -77,8 +77,8 @@ trait BitraverseConversions extends BifunctorConversions with BifoldableConversi
7777
private[conversions] trait BitraverseShimS2C[F[_, _]] extends cats.Bitraverse[F] with BifunctorShimS2C[F] with BifoldableShimS2C[F] {
7878
val F: scalaz.Bitraverse[F]
7979

80-
override def bitraverse[G[_]: cats.Applicative, A, B, C, D](fab: F[A, B])(f: A => G[C], g: B => G[D]): G[F[C, D]] =
81-
F.bitraverse(fab)(f)(g)
80+
override def bitraverse[G[_]: cats.Applicative, A, B, C, D](fab: F[A, B])(f: A => G[C], g: B => G[D]): G[F[C, D]] = ???
81+
// F.bitraverse(fab)(f)(g)
8282
}
8383

8484
implicit def bitraverseToCats[F[_, _], T](implicit FC: Capture[scalaz.Bitraverse[F], T], ev: T </< Synthetic): cats.Bitraverse[F] with Synthetic =
@@ -87,8 +87,8 @@ trait BitraverseConversions extends BifunctorConversions with BifoldableConversi
8787
private[conversions] trait BitraverseShimC2S[F[_, _]] extends scalaz.Bitraverse[F] with BifunctorShimC2S[F] with BifoldableShimC2S[F] {
8888
val F: cats.Bitraverse[F]
8989

90-
override def bitraverseImpl[G[_]: scalaz.Applicative, A, B, C, D](fab: F[A, B])(f: A => G[C], g: B => G[D]): G[F[C, D]] =
91-
F.bitraverse(fab)(f, g)
90+
override def bitraverseImpl[G[_]: scalaz.Applicative, A, B, C, D](fab: F[A, B])(f: A => G[C], g: B => G[D]): G[F[C, D]] = ???
91+
// F.bitraverse(fab)(f, g)
9292
}
9393

9494
implicit def bitraverseToScalaz[F[_, _], T](implicit FC: Capture[cats.Bitraverse[F], T], ev: T </< Synthetic): scalaz.Bitraverse[F] with Synthetic =

core/src/main/scala/shims/conversions/datatypes.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ trait FreeConverters extends MonadConversions {
4848

4949
implicit def freeAs[S[_], A] = new AsScalaz[cats.free.Free[S, A], scalaz.Free[S, A]] with AsCats[scalaz.Free[S, A], cats.free.Free[S, A]] {
5050

51-
def c2s(f: cats.free.Free[S, A]) =
52-
f.foldMap[scalaz.Free[S, ?]](λ[FunctionK[S, scalaz.Free[S, ?]]](scalaz.Free.liftF(_)))
51+
def c2s(f: cats.free.Free[S, A]) = ???
52+
// f.foldMap[scalaz.Free[S, ?]](λ[FunctionK[S, scalaz.Free[S, ?]]](scalaz.Free.liftF(_)))
5353

54-
def s2c(f: scalaz.Free[S, A]) =
55-
f.foldMap[cats.free.Free[S, ?]](λ[S ~> cats.free.Free[S, ?]](cats.free.Free.liftF(_)))
54+
def s2c(f: scalaz.Free[S, A]) = ???
55+
// f.foldMap[cats.free.Free[S, ?]](λ[S ~> cats.free.Free[S, ?]](cats.free.Free.liftF(_)))
5656
}
5757
}
5858

@@ -66,7 +66,7 @@ trait EvalConverters extends FreeConverters {
6666
// the inner workings of eval aren't exposed, so we can't do any better here
6767
def c2s(e: Eval[A]) = Trampoline.delay(e.value)
6868

69-
def s2c(t: FT[A]) = t.foldMap(λ[Function0 ~> Eval](a => Eval.always(a())))
69+
def s2c(t: FT[A]) = ??? // t.foldMap(λ[Function0 ~> Eval](a => Eval.always(a())))
7070
}
7171
}
7272

@@ -75,11 +75,11 @@ trait StateTConverters extends MonadConversions {
7575
implicit def stateTAs[F[_]: cats.Monad, S, A] =
7676
new AsScalaz[cats.data.StateT[F, S, A], scalaz.StateT[F, S, A]] with AsCats[scalaz.StateT[F, S, A], cats.data.StateT[F, S, A]] {
7777

78-
def c2s(st: cats.data.StateT[F, S, A]) =
79-
scalaz.StateT[F, S, A](s => cats.Monad[F].flatMap(st.runF)(_(s)))
78+
def c2s(st: cats.data.StateT[F, S, A]) = ???
79+
// scalaz.StateT[F, S, A](s => cats.Monad[F].flatMap(st.runF)(_(s)))
8080

81-
def s2c(st: scalaz.StateT[F, S, A]) =
82-
cats.data.StateT[F, S, A](st.run(_))
81+
def s2c(st: scalaz.StateT[F, S, A]) = ???
82+
// cats.data.StateT[F, S, A](st.run(_))
8383
}
8484
}
8585

core/src/main/scala/shims/conversions/monad.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ trait FoldableConversions extends MonoidConversions with ApplicativeConversions
149149
private[conversions] trait FoldableShimC2S[F[_]] extends scalaz.Foldable[F] with Synthetic {
150150
val F: cats.Foldable[F]
151151

152-
override def foldMap[A, B](fa: F[A])(f: A => B)(implicit B: scalaz.Monoid[B]): B =
153-
F.foldMap(fa)(f)
152+
override def foldMap[A, B](fa: F[A])(f: A => B)(implicit B: scalaz.Monoid[B]): B = ???
153+
// F.foldMap(fa)(f)
154154

155155
override def foldRight[A, B](fa: F[A], z: => B)(f: (A, => B) => B): B =
156156
F.foldRight(fa, Eval.always(z))((a, b) => b.map(f(a, _))).value
@@ -165,8 +165,8 @@ trait TraverseConversions extends ApplicativeConversions with FoldableConversion
165165
private[conversions] trait TraverseShimS2C[F[_]] extends cats.Traverse[F] with FunctorShimS2C[F] with FoldableShimS2C[F] {
166166
val F: scalaz.Traverse[F]
167167

168-
override def traverse[G[_]: cats.Applicative, A, B](fa: F[A])(f: A => G[B]): G[F[B]] =
169-
F.traverse(fa)(f)
168+
override def traverse[G[_]: cats.Applicative, A, B](fa: F[A])(f: A => G[B]): G[F[B]] = ???
169+
// F.traverse(fa)(f)
170170
}
171171

172172
implicit def traverseToCats[F[_], T](implicit FC: Capture[scalaz.Traverse[F], T], ev: T </< Synthetic): cats.Traverse[F] with Synthetic =
@@ -175,8 +175,8 @@ trait TraverseConversions extends ApplicativeConversions with FoldableConversion
175175
private[conversions] trait TraverseShimC2S[F[_]] extends scalaz.Traverse[F] with FunctorShimC2S[F] with FoldableShimC2S[F] {
176176
val F: cats.Traverse[F]
177177

178-
override def traverseImpl[G[_]: scalaz.Applicative, A, B](fa: F[A])(f: A => G[B]): G[F[B]] =
179-
F.traverse(fa)(f)
178+
override def traverseImpl[G[_]: scalaz.Applicative, A, B](fa: F[A])(f: A => G[B]): G[F[B]] = ???
179+
// F.traverse(fa)(f)
180180
}
181181

182182
implicit def traverseToScalaz[F[_], T](implicit FC: Capture[cats.Traverse[F], T], ev: T </< Synthetic): scalaz.Traverse[F] with Synthetic =

core/src/main/scala/shims/package.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import shims.conversions._
1818

1919
package object shims
2020
extends MonadConversions
21-
with OrderConversions
21+
with MonoidConversions
2222
with BitraverseConversions
2323
with ChoiceConversions
2424
with EitherConverters

core/src/test/scala/shims/KernelConversionSpecs.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ import org.typelevel.discipline.specs2.mutable.Discipline
2424

2525
object KernelConversionSpecs extends Specification with Discipline {
2626

27+
"eq conversion" >> {
28+
cats.Eq[Int]
29+
scalaz.Equal[Int]
30+
31+
"scalaz -> cats" >> {
32+
checkAll("Int", OrderLaws[Int].eqv)
33+
}
34+
}
35+
2736
"order conversion" >> {
2837
cats.Order[Int]
2938
scalaz.Order[Int]

core/src/test/scala/shims/MonadConversionSpecs.scala

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,53 @@ object MonadConversionSpecs extends Specification with Discipline {
172172
}
173173

174174
"Free[Function0, ?]" >> {
175-
import scalaz.Free
175+
import cats.kernel.Eq
176+
import cats.instances.list._
176177

177-
trait Foo[A]
178+
import scalaz.{~>, Free}
179+
180+
case class Foo[A](a: A)
181+
182+
implicit def arbFreeFoo[A: Arbitrary: Cogen]: Arbitrary[Free[Foo, A]] = {
183+
val genPure: Gen[Free[Foo, A]] = arbitrary[A].map(Free.point(_))
184+
185+
val genLiftF: Gen[Free[Foo, A]] =
186+
arbitrary[A].map(a => Free.liftF(Foo[A](a)))
187+
188+
val genBind: Gen[Free[Foo, A]] = for {
189+
s <- arbitrary[Free[Foo, A]]
190+
f <- arbitrary[A => Free[Foo, A]]
191+
} yield s.flatMap(f)
192+
193+
val g = Gen.frequency(
194+
1 -> genPure,
195+
1 -> genLiftF,
196+
3 -> genBind)
197+
198+
Arbitrary(g)
199+
}
200+
201+
{
202+
implicit val eqStr: Eq[String] = null
203+
204+
Eq[List[String]]
205+
}
206+
207+
implicit def eqFree[A: Eq]: Eq[Free[Foo, A]] = {
208+
Eq instance { (f1, f2) =>
209+
val nt = λ[Foo ~> List](fa => List(fa.a))
210+
211+
val as1 = f1.foldMap(nt)
212+
val as2 = f2.foldMap(nt)
213+
214+
Eq[List[A]].eqv(as1, as2)
215+
}
216+
}
178217

179218
cats.Monad[Free[Foo, ?]]
180219
scalaz.Monad[Free[Foo, ?]]
181220

182-
ok // TODO
221+
checkAll("Free[Foo, ?]", MonadTests[Free[Foo, ?]].monad[Int, Int, Int])
183222
}
184223
}
185224
}

0 commit comments

Comments
 (0)