Git Product home page Git Product logo

droste's Introduction

Droste

Join the chat at https://gitter.im/higherkindness/droste

Droste is a recursion library for Scala.

SBT installation

Select a tagged release version (x.y.z) and then add the following to your SBT build:

libraryDependencies += "io.higherkindness" %% "droste-core" % "x.y.z"

Usage

Droste makes it easy to assemble morphisms. For example, calculating Fibonacci values can be done with a histomorphism if we model natural numbers as a chain of Option. We can easily unfold with an anamorphism and then fold to our result with a histomorphism.

import higherkindness.droste._
import higherkindness.droste.data._

val natCoalgebra: Coalgebra[Option, BigDecimal] =
  Coalgebra(n => if (n > 0) Some(n - 1) else None)

val fibAlgebra: CVAlgebra[Option, BigDecimal] = CVAlgebra {
  case Some(r1 :< Some(r2 :< _)) => r1 + r2
  case Some(_ :< None)           => 1
  case None                      => 0
}

val fib: BigDecimal => BigDecimal = scheme.ghylo(
  fibAlgebra.gather(Gather.histo),
  natCoalgebra.scatter(Scatter.ana))
fib(0)
// res0: BigDecimal = 0
fib(1)
// res1: BigDecimal = 1
fib(2)
// res2: BigDecimal = 1
fib(10)
// res3: BigDecimal = 55
fib(100)
// res4: BigDecimal = 354224848179261915075

An anamorphism followed by a histomorphism is also known as a dynamorphism. Recursion scheme animals like dyna are available in the zoo:

val fibAlt: BigDecimal => BigDecimal =
  scheme.zoo.dyna(fibAlgebra, natCoalgebra)
fibAlt(0)
// res5: BigDecimal = 0
fibAlt(1)
// res6: BigDecimal = 1
fibAlt(2)
// res7: BigDecimal = 1
fibAlt(10)
// res8: BigDecimal = 55
fibAlt(100)
// res9: BigDecimal = 354224848179261915075

What if we want to do two things at once? Let's calculate a Fibonacci value and the sum of all squares.

val fromNatAlgebra: Algebra[Option, BigDecimal] = Algebra {
  case Some(n) => n + 1
  case None    => 0
}

// note: n is the fromNatAlgebra helper value from the previous level of recursion
val sumSquaresAlgebra: RAlgebra[BigDecimal, Option, BigDecimal] = RAlgebra {
  case Some((n, value)) => value + (n + 1) * (n + 1)
  case None             => 0
}

val sumSquares: BigDecimal => BigDecimal = scheme.ghylo(
  sumSquaresAlgebra.gather(Gather.zygo(fromNatAlgebra)),
  natCoalgebra.scatter(Scatter.ana))
sumSquares(0)
// res10: BigDecimal = 0
sumSquares(1)
// res11: BigDecimal = 1
sumSquares(2)
// res12: BigDecimal = 5
sumSquares(10)
// res13: BigDecimal = 385
sumSquares(100)
// res14: BigDecimal = 338350

Now we can zip the two algebras into one so that we calculate both results in one pass.

val fused: BigDecimal => (BigDecimal, BigDecimal) =
  scheme.ghylo(
    fibAlgebra.gather(Gather.histo) zip
    sumSquaresAlgebra.gather(Gather.zygo(fromNatAlgebra)),
    natCoalgebra.scatter(Scatter.ana))
fused(0)
// res15: (BigDecimal, BigDecimal) = (0, 0)
fused(1)
// res16: (BigDecimal, BigDecimal) = (1, 1)
fused(2)
// res17: (BigDecimal, BigDecimal) = (1, 5)
fused(10)
// res18: (BigDecimal, BigDecimal) = (55, 385)
fused(100)
// res19: (BigDecimal, BigDecimal) = (354224848179261915075, 338350)

Droste includes athema, a math expression parser/processor, as a more extensive example of recursion schemes.

Credits

A substantial amount of Droste's code is a derivation-- or an alternative encoding-- of patterns pioneered by others. Droste has benefited from the excellent work in many other recursion libraries, blog posts, academic papers, etc. Notably, Droste has benefited from:

Thank you to everyone involved. Additionally, thanks to Greg Pfeil (@sellout) for answering my random questions over the last few years while I've been slowly learning (and using recursion) schemes.

Copyright and License

Copyright the maintainers, 2018-present.

All code is available to you under the Apache License, Version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0.

Logos provided by the very excellent @impurepics.

Disclamer

Please be advised that I have no idea what I am doing. Nevertheless, this project is already being used for real work with real data in real life.

droste's People

Contributors

47erbot avatar alejandrohdezma avatar andyscott avatar angoglez avatar antoniomateogomez avatar bluemoon avatar caenrique avatar cb372 avatar ceedubs avatar clayrat avatar custommonkey avatar daenyth avatar davesmith00047 avatar fedefernandez avatar github-actions[bot] avatar gitter-badger avatar juanpedromoreno avatar oleg-py avatar pepegar avatar scala-steward avatar sloshy avatar travisbrown avatar txsmith avatar tzimisce012 avatar voltir avatar xton avatar xton-stripe avatar xuwei-k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

droste's Issues

Housekeeping

I'm planning on doing a couple of housekeeping chores for Droste:

  • Update to an easier to use nix-shell
  • Review PRs, and library versions
  • Review installed plugins
  • Merge the docs PR that we had lying around somewhere
  • Make sure the microsite works correctly

@deriveTraverse annotation should support sealed trait families

Currently, the deriveTraverse annotation supports sealed trait hierarchies whose members do not reference other sealed trait hierarchies, but it would be nice for the deriveTraverse annotation to support a structure like this:

sealed trait TreeF[A]

sealed trait FieldF[A] 

object TreeF {
  final case class NamedField[A](fieldName: String, tpe: A) extends FieldF[A]
  final case class NumberedField[A](fieldNumber: Int, tpe: A) extends FieldF[A]

  final case class BranchF[A](left: A, right: A) extends TreeF[A]
  final case class NodeF[A](name: String, a: FieldF2[A]) extends TreeF[A]
}

Where TreeF's Node class contains a field which is itself a member of another sealed trait, FieldF.

I've written a minimal reproduction of this request here. With the Playground class file being the entry point showing the difference in behavior between the deriveTraverse macro and a manually written Traverse instance.

Main Features Documentation

In order to publish the microsite, we need to add the basic documentation.
At the moment we have got the Quick Start guide, but we need docs for the 3 top-level sections that will be displayed in the features section, in the home page.
This is how this features section will looks like, as @pepegar proposed in the "Higherkindness" channel.

captura de pantalla 2018-10-09 a las 12 56 02

So, the first step to publish it would be adding those three top-level features "Data Structures", "Type Classes" and "Recursion Schemes".

potential surprise bonus features of Mu extending ~>

Mu is defined as extending Algebra[F, ?] ~> Id. In addition to inheriting the apply method from ~>, this also means that it inherits some methods like andThen, compose, and, and or.

In a project of mine I was using Mu to represent regular expressions, and this caught me by surprise, because I tried to add andThen and or syntax to combine two regular expressions and ran into a name collision with the methods from ~>.

I'm definitely not saying that this needs to be changed. I'm not even using Mu to represent regular expressions anymore, and nobody is using that library anyway. But I just thought that I would bring it up so to ensure that it's a conscious decision to inherit these other methods. Feel free to close this out without changes.

Compile to Scala3

It would be great to start working on making Droste compile to Scala3

DefaultTraverse doesn't pass all Traverse laws

It's possible that I'm doing something silly here, but I thought that I would report in case that's not what's happening. Either way, it would probably be good for droste to be doing more law-checking in tests.

Consider the following simple data type:

import cats.implicits._
import qq.droste.util.DefaultTraverse
import cats.{Applicative, Eq, Traverse}
import org.scalacheck.Arbitrary

final case class Pair[A](l: A, r: A)

object Pair {

  implicit val traversePair: Traverse[Pair] = new DefaultTraverse[Pair] {
    def traverse[G[_], A, B](fa: Pair[A])(f: A => G[B])(implicit G: Applicative[G]): G[Pair[B]] =
      G.map2(f(fa.l), f(fa.r))(Pair(_, _))
  }

  implicit def eqPair[A](implicit eqA: Eq[A]): Eq[Pair[A]] = Eq.instance((p1, p2) =>
    p1.l === p2.l && p1.r === p2.r
  )
}

Now run the following test:

import cats.tests.CatsSuite
import cats.laws.discipline.TraverseTests

class DefaultTraverseTests extends CatsSuite {
  implicit def arbPair[A](implicit arbA: Arbitrary[A]): Arbitrary[Pair[A]] = Arbitrary(
    arbA.arbitrary.flatMap(a1 => arbA.arbitrary.map(a2 => Pair(a1, a2))))

  checkAll("Pair", TraverseTests[Pair].traverse[Int, Int, Int, Set[Int], Option, Option])
}

The collectFirstSome and foldM identity laws consistently fail. Here is some example output:

- Pair.traverse.collectFirstSome reference *** FAILED ***
  GeneratorDrivenPropertyCheckFailedException was thrown during property evaluation.
   (Discipline.scala:14)
    Falsified after 10 successful property evaluations.
    Location: (Discipline.scala:14)
    Occurred when passed generated values (
      arg0 = Pair(1,1284725810),
      arg1 = org.scalacheck.GenArities$$Lambda$11995/1290092155@1195eb5b
    )
    Label of failing property:
      Expected: Some(Set())
  Received: Some(Set(-1))
- Pair.traverse.foldM identity *** FAILED ***
  GeneratorDrivenPropertyCheckFailedException was thrown during property evaluation.
   (Discipline.scala:14)
    Falsified after 5 successful property evaluations.
    Location: (Discipline.scala:14)
    Occurred when passed generated values (
      arg0 = Pair(0,2147483647),
      arg1 = Set(2061683075),
      arg2 = org.scalacheck.GenArities$$Lambda$12122/454406410@5b35771c
    )
    Label of failing property:
      Expected: Set()
  Received: Set(-225533737)

Both of these are ultimately implemented in terms of foldRight, so I suspect that there is an issue with the DefaultTraverse.foldRight implementation.

Example usage of droste with expressions of varying inner types

I have looked at higherkindness.athema.Expr[V, A] and it seems to provide type variable V for certain expressions.

I have an expression tree that I would like to define similar to above but what makes it unique is that there are at least five different base types if you will where expressions would require and only work with one of those base types. My thought was to define a type something like:

sealed trait Expr[A, B, C, D, E]
case class OpOnA[A, B, C, D, E](a: A) extends Expr[A, B, C, D, E]
case class CombineOnlyAsAndBs[A, B, C, D, E](a: A, b: B) extends Expr[A, B, C, D, E]
case class ConvertBToC[A, B, C, D, E](b: B, someValue: String) extends Expr[A, B, C, D, E]
case class RunC[A, B, C, D, E](c: C, time: Int) extends Expr[A, B, C, D, E]
...

Am I on the right track with the above? If so how do I use Fix with so many type parameters on Expr?

If not is there a more in depth example of droste that I can look at that has a similar constraint?

Question: Why Yoneda in postpro/prepro?

When I am looking at the code: https://github.com/higherkindness/droste/blob/master/modules/core/src/main/scala/higherkindness/droste/zoo.scala#L133

 def postpro[F[_]: Functor, A, R](
      coalgebra: Coalgebra[F, A],
      natTrans: F ~> F
  )(implicit embed: Embed[F, R]): A => R =
    kernel.hylo[Yoneda[F, ?], A, R](
      yfb => embed.algebra.run(yfb.run),
      coalgebra.run.andThen(fa => Yoneda.apply[F, A](fa).mapK(natTrans))
    )

I am curious why use Yoneda here? given that Yoneda[F,A] is isomorphic to F[A]. thanks

droste.syntax.fix enables unsafe casting

I think the following code should be rejected, because it will cause runtime cast exception:

  val natRCo2 = RCoalgebra[Fix[Option], Option, Int] {
    (n: Int) => if (n > 0) Some(Left(Some(1).fix)) else None
  }

while, if I use Fix.apply, it correctly shows a compilation error:

  val natRCo = RCoalgebra[Fix[Option], Option, Int] {
    (n: Int) => if (n > 0) Some(Left(Fix[Option](Some(1)))) else None
  }

the compiler shows:

Description Resource Path Location Type
type mismatch;  found   : Int(1)  required: qq.droste.data.Fix[Option]

does it mean that .fix is not safe?

Recursion scheme friendly names for Free/Cofree and pattern functors

I've been considering a rename of Free/Cofree and CoenvT/EnvT.

  • Cofree/EnvT to Attr/AttrF
  • Free/CoenvT to Coattr/CoattrF

The documentation for these items would still note that they are Free, Cofree, etc. The main motivation is to reduce the cognitive overhead. The "Attr" name for attributing/annotating trees shows up in existing recursion scheme documentation (such as https://blog.sumtypeofway.com/recursion-schemes-part-iv-time-is-of-the-essence/), so the name isn't new. Remembering the pattern functor for Cofree & Free could be easy, but right now you have to be aware of EnvT and CoenvT.

What do others think?

Why (co)algebra classes final?

Any good reason to keep it final? I found useful to define an abstract class with helper function for building complex algebra, I think it would be nice to extend algebra class itself.

Unapply seems to fail on Cofree

Consider this function (adapted from https://jtobin.io/time-traveling-recursion):

def oddIndices[A]: List[A] => List[A] =
  scheme.zoo.histo[ListF[A, ?], List[A], List[A]](
    CVAlgebra[ListF[A, ?], List[A]] {
      case NilF => Nil
      case ConsF(h, _ :< NilF) => List(h)
      case ConsF(h, _ :< ConsF(_, t :< _)) => h :: t
    }
  )

This fails to compile with the following error (corresponds to the ConsF(h, _ :< NilF) case):

Error:(21, 28) pattern type is incompatible with expected type;
 found   : qq.droste.data.list.NilF.type
 required: F[qq.droste.data.Cofree[F,A]] forSome { type A; type F[_]; type F[_]; type A }
        case ConsF(h, _ :< NilF) => List(h)

Apparently it can't figure out that F is ListF[A, ?] here? A workaround is to unwrap manually:

def oddIndices[A]: List[A] => List[A] =
  scheme.zoo.histo[ListF[A, ?], List[A], List[A]](
    CVAlgebra[ListF[A, ?], List[A]] {
      case NilF => Nil
      case ConsF(h, coa) => Cofree.un[ListF[A, ?], List[A]](coa) match {
        case (_, NilF) => List(h)
        case (_, ConsF(_, coa2)) => h :: Cofree.un[ListF[A, ?], List[A]](coa2)._1
      }
    }
  )

derived Traverse fails on case objects

Consider the following Option-like ADT:

@deriveTraverse
sealed abstract class MyExprF[+A] extends Product with Serializable

object MyExprF {
  final case class Const[+A](value: A) extends MyExprF[A]
  case object Noll extends MyExprF[Nothing]
}

The derived traverse method in the Traverse instance throws a MatchError on the Noll case:

scala> import cats.implicits._
import cats.implicits._

scala> val c: MyExprF[Int] = Const(3)
c: qq.droste.examples.MyExprF[Int] = Const(3)

scala> c.traverse(Option.apply) // expected output
res0: Option[qq.droste.examples.MyExprF[Int]] = Some(Const(3))

scala> val n: MyExprF[Int] = Noll
n: qq.droste.examples.MyExprF[Int] = Noll

scala> n.traverse(Option.apply) // I would expect Some(Noll)
scala.MatchError: Noll (of class qq.droste.examples.MyExprF$Noll$)
  at qq.droste.examples.MyExprF$$anon$1.traverse(TestExpr.scala:6)
  at qq.droste.examples.MyExprF$$anon$1.traverse(TestExpr.scala:6)
  at cats.Traverse$Ops.traverse(Traverse.scala:19)
  at cats.Traverse$Ops.traverse$(Traverse.scala:19)
  at cats.Traverse$ToTraverseOps$$anon$3.traverse(Traverse.scala:19)
  ... 36 elided

Flaky test on StreamTests.monoid.combine all

failing seed for monoid.combine all is SGFUZ_W1vdaXG1UjmoN6qgg9wwl7yimZDfxvf7fWOIG=
failing seed for StreamTests.monoid.combine all is SGFUZ_W1vdaXG1UjmoN6qgg9wwl7yimZDfxvf7fWOIG=
[info] ! StreamTests.monoid.combine all: Exception raised on property evaluation.
[info] > ARG_0: Vector(Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(2147483647, 1, 1, 679659312, 954955335)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(2125081776, 2082780184, 2124224095, 1, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 2101629868, 1, 614890913, 1, 570496610, 1, 1, 556549726, 2147483647, 1422404084, 1543029277, 1, 2147483647, 1, 2147483647, 1681280044, 2147483647, 252381599)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(2114611335, 1048617635, 1, 1, 1, 602085295, 1, 1455116067, 1918134503, 2147483647, 1, 1078844531, 224218324, 1, 838532682, 697955766, 1933075727, 1, 1663880333, 1, 1073357867, 1, 1348448454)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(567192055, 1, 1, 1, 1032163586, 290523710, 1531883113, 2147483647, 1, 1430171065, 1350062717, 1, 1101732834, 1, 2046407204, 2147483647, 436460317, 1, 1223118908, 1, 1, 1414963960, 1, 2147483647, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 1, 1135301754, 562231227, 1, 1523173891, 202420779, 1, 725261016, 1, 1911901655)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1266206836, 1281911212, 1, 222025663, 1746414387, 19432543, 1, 1, 1, 2139320421, 275523534, 317001164, 1061151090, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 1, 665986870, 1507860748, 2147483647, 1986206027, 1123203079, 2147483647)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(642344075, 2147483647, 645479572, 2147483647, 1899143917, 1, 1, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(270808965, 2147483647, 1, 1236048225, 2147483647, 2040816209, 1, 2147483647, 665104386, 1215235948, 1, 2147483647, 1, 1172305762, 2147483647, 1, 2147483647, 1208741378, 2147483647, 2147483647, 1, 526842217)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 409725053, 271699911)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1224097095, 1, 881558065, 1, 1593599721, 2049894488, 1, 1139159556, 1274564299, 593361024, 1, 1, 1, 1, 2136663038)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(2147483647, 1, 350525858, 1283235651, 432490327, 1, 1409596594, 90279600, 1, 2147483647, 1058706063, 1823389376, 2147483647, 620115439, 1, 408137558, 1, 1, 1744242409, 2114698374, 2147483647, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 1, 1219070300, 2147483647, 1, 1, 1435992328, 1038610951, 1, 1, 1, 1, 1195244259, 2147483647, 1, 2002552969, 1792833092, 1, 817979872, 1133498025, 1303922440, 1, 1, 1135051448)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(2147483647, 1, 1852117331, 1, 1476282852, 1003516898, 1988510468, 2147483647, 1324262728, 521039708, 1954483877, 2095012383, 574156516, 1, 1, 1, 206402335, 2092943740)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 1, 1075553293, 1, 1138513339, 1, 1, 1294678022, 1, 1, 1602074395, 2098430925, 1474835889, 1, 158408005, 1862999169, 1, 1484057522, 653559863, 39275168, 1935392827, 1438914817, 1, 1247999141, 1043067731)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(786704446, 1, 1191869128, 2147483647, 1512168288, 1, 1, 2147483647, 320247815, 1, 1190924638, 872692366, 719469191, 470383669, 219793174, 2132167294, 254004770, 935668338, 755591424, 1, 811816622, 2147483647, 1407731747, 2102566632)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 1516391419)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 2147483647, 1684173442, 1, 2147483647, 1, 304629208, 1, 872568053, 1, 906470601)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 1081091179, 1, 252635250, 1362169305, 2147483647, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(2124511720, 1, 1993230725, 1, 33774500, 2147483647, 302517813, 1212741271, 1, 1730781783, 1, 1095759818, 2147483647, 412612355)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(668021859, 348847735, 1336253581, 1, 1003315250, 898427842, 2147483647, 1295762386, 900779410, 1, 122543801, 1651921537, 1, 1253966284)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(799379640, 1039633698, 1, 1, 1, 2147483647, 2147483647, 1, 1, 1377181048, 1, 470746397, 2147483647, 535824453, 59187667, 2147483647, 1, 1331920481, 1708420228, 464581277, 1628864210, 1910617905, 1098630113, 1211132244)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1588061394, 1803051391, 22905021, 1, 659118469, 1611391737, 1, 1, 1, 1248579657, 2147483647, 1836808964, 1, 2025174188, 2147483647, 3840602)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 1, 2147483647, 124660848, 2147483647, 1, 1, 909196089, 1080897059)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 419603591, 1, 1484099302, 845197922, 1, 1, 2147483647, 1759080945, 2147483647, 641536731, 302112261, 69587926, 622414508, 1, 2147483647, 1812720887, 1, 1, 1, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(2147483647, 646797729, 37782387, 1, 2147483647, 1, 1, 2147483647, 1, 1, 1896466734, 1938742555, 1815618045, 304267207, 147737586)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 1, 1, 1723532970, 2147483647, 732729109, 2147483647)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(2147483647, 1, 1, 1, 1873532571, 1806033343, 809195081, 1, 1380207689, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(690253101, 1, 99933646, 2147483647, 135715074, 1, 1819796239, 1, 1218777509, 1, 430984681, 1101782568, 1, 2147483647, 2147483647, 229660529, 1977207601, 2147483647, 1864875004, 1, 1717269415, 333316059, 2147483647, 268851481)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 1, 1505033835, 1309256244, 2147483647, 2147483647, 1, 1, 1871607918, 2147483647, 1156583888, 1544175209, 1, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List()), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(2147483647, 2147483647, 1904661623, 617630259, 469913286, 2147483647, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1211041125, 191761631, 2147483647, 54708091, 2147483647, 1, 1, 2147483647, 1, 1, 2147483647, 2147483647, 967058446, 1, 311342654, 2147483647, 1, 2147483647, 1458556085)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List()), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(104494811, 1958418488, 1, 2147483647, 1, 478219860, 924903348, 1038439822, 2147483647, 1, 30187977, 1, 1, 2147483647, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(2147483647, 2147483647, 1301705524, 625408975, 1720333359, 975008142, 233433908)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1473264163, 920984020, 1854360108, 1, 758956917, 660667340, 744123260, 1, 1677353808, 832428521, 796969398)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 1, 2147483647, 1371207125, 2147483647, 1949659641, 742909062, 864958502, 942351461, 1115543179, 1281791724, 1735135451, 1004515067, 1, 1, 1583830892, 1450019011, 1433030689, 992577953)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(840913784, 2147483647, 1811961645, 573616035, 733909960, 2147483647, 1, 1307164353, 2147483647, 1, 954590061, 1, 1095174408, 2147483647, 2147483647, 569848947, 2147483647, 645041760, 1150405877)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 691313931, 1517411156, 1833446943, 1, 2147483647, 1, 2147483647, 2147483647, 1, 513046041, 1297409852, 1570022130, 2044282459)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(2147483647, 403534590, 1114817653, 1, 1196493923, 1886030109, 443171106, 1, 2018975431, 531047608, 1, 890540801)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(196900303, 605650082, 109031204, 1838014081, 1336476691, 997843238, 1, 1496936852, 1889791938, 2147483647, 2147483647, 1, 2005993078, 675642292, 1999030970, 2147483647, 1, 1519956364, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(231288691, 1, 1, 1, 945500603, 1, 1877810146, 1, 1, 1, 1, 2147483647, 1696593695, 2147483647, 1, 1, 1, 2147483647, 1595130665, 1470817478, 1100889653, 1, 2147483647, 2147483647, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1151566272, 2147483647, 1418266427, 1, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(2147483647, 1598882541, 1, 1, 2147483647, 1, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1424705369, 1, 2147483647, 1, 59283700, 1, 1280492479, 436425255, 1, 1, 1119707536, 102681199, 532188777, 492990450, 295379106, 1397015655, 1, 1658785587, 1, 1, 835885617, 1105246176, 1301491896)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1775659553, 1606427200, 1, 1, 1717325429, 1, 1, 1125464665, 1, 1499816236, 1382158409, 1, 1, 1, 9288898, 1087282707, 2020190400, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 673230047, 70201043, 1554954667, 758770773, 257627613, 1418429597, 1793096598, 2147483647, 1, 228940212, 1228669053, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(2147483647, 1698693639, 1, 1, 1362274108, 264708816, 1, 2147483647, 1, 1539319649, 1, 2147483647)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(2147483647, 2147483647, 1185692689, 452611100, 1, 231251795, 1, 1056785950, 1189090275, 2147483647, 1804568161, 1, 2147483647, 1876140493, 1294784996, 1792040040, 1, 1347903253)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1507357379, 1, 2147483647, 1, 1, 2147483647, 2147483647, 370371002, 1111671147, 1, 1, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 1, 1, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(335902291, 1, 223363711, 728506813, 1, 1, 1, 1, 1607688303, 2147483647, 389917280, 1730547816, 675063844, 1, 2003358852, 1, 1, 1805300011, 1369061604, 384167665)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List()), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 2147483647, 2147483647, 1154326454, 343940142, 1743693239, 1268759226, 1119447479, 2147483647, 1, 1532649730, 41209785, 139753626, 1, 1, 1876613607, 1533750994, 1961133638, 1763671558, 1, 8627849)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1527361723, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List()), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1819590451, 1, 2147483647, 2147483647, 2147483647, 564867791, 2147483647, 1, 27720828, 2147483647, 2147483647, 1490298448)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(2147483647, 1, 1111682307, 2108449125, 45087529)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 2147483647, 1514532592, 152417755, 1, 1, 2147483647, 1, 2147483647, 1, 1, 2147483647, 1, 2147483647, 2147483647, 2147483647, 1, 1, 1254116366, 2147483647, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 927562542, 2147483647, 1476261974, 1486462430, 1209509791, 2147483647, 796175912, 1081756363, 1, 2108546787, 1, 984129397, 692352858, 717112744, 1, 1, 1, 2147483647, 761413041, 353940100, 1, 1, 2147483647, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(851429222)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 2027177132, 288788594, 1798265610, 1408756957, 2147483647, 1315967551, 2147483647, 1, 2147483647, 500157551, 1, 2147483647, 1, 129650830, 635599834, 1133197920, 579147987, 1841152889, 1, 1729605800, 2147483647, 1, 1, 292473511)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 2147483647, 1, 777598365, 1, 1991556757, 482353418, 1, 595902920, 387454901, 1585802945, 2147483647, 845767196, 1, 1244271434, 1103310261, 947980654, 1, 1683229705, 2129658104, 269864302, 365498963, 2147483647, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 2147483647, 1004549005, 1348519267)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(2147483647)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1800583405, 927815235, 1475436947, 1, 1, 1, 2147483647, 1207980702, 1, 1, 1, 1, 1972685833)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(619662675, 2019718466)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(2147483647, 682664669, 518116251, 1, 1, 1, 208862121, 1, 1899170232, 1067975670, 1, 1498858184, 453031777, 1233030219)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(675772710, 1, 1507355149, 1854984873, 549284467, 2104127321, 1, 1, 1152075363, 1966252665, 1, 2147483647, 1, 1, 998624948, 1, 2087697294, 1, 542078646, 1999352857, 1, 603722603, 23342694, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List()), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(35208606, 1758023009, 1, 1477881879, 191565165, 1, 1161486524, 2147483647, 1352243694, 1, 2147483647, 1258245088, 1, 460748313, 1, 1, 1, 1, 1, 1, 1117072481, 1249579374, 2147483647)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(671263953, 1, 2147483647, 512824971, 1099675033, 1977472265, 1, 1, 1734064454, 1878901495, 661925796, 1755954085)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 96759344, 722737719, 1, 2139825347, 2147483647, 1, 1, 102211532, 1, 2108346440, 770982901, 1007290573, 2147483647, 1172566839, 1, 568256911, 2147483647, 585118692, 1, 1, 1, 1, 1281670026)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(622299692, 854652252, 1, 366988103, 69853622, 1515637615, 2147483647, 1, 395680227, 2147483647, 1, 1, 2147483647, 1, 2048998501, 2147483647, 1, 1, 467506222, 1, 2147483647)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(2147483647, 2147483647, 2147483647, 1, 1476018609, 1, 2147483647, 321002258, 1766476897, 1241908369, 2147483647, 795396216, 1, 1, 1, 1, 836113159, 1349523410, 1, 2147483647, 2118205942, 281321694, 787292568, 2147483647)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(2147483647, 1833431142, 1, 1, 1, 2104891075, 1062289932, 1, 1, 1, 1, 518780273)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 2147483647, 2147483647, 2068389302, 1929430384, 1753446747, 2147483647, 1, 2147483647, 1, 644711971, 2147483647, 2147483647)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 1, 918200297, 1786745447, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1869590697, 1, 1868718077, 1606828414, 2147483647, 1815436620, 1, 1, 1037228942, 1477985658, 1482775868, 51848076, 1, 1, 1275800968, 1472366265, 1, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1920074440, 1053414933, 1, 2122763324, 1, 1887901801, 1, 1026397121, 381329904, 452648983, 1259662571, 1301518597, 777815026, 1, 1, 650963203, 1296336475, 336993432, 2147483647, 1, 1, 2147483647)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 1, 1, 1, 2147483647, 2147483647, 986023681, 2147483647, 1159962519, 2147483647, 2147483647, 2147483647, 2147483647, 1043683387, 2147483647)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1641821935, 415612912, 1, 1027669559, 1, 1222479296, 997876144)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(2020519796, 1, 1998748020, 1, 1262091764, 1, 1, 1, 1800930139, 601711576, 1, 819174806)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 2141088759, 2147483647, 1, 737534352, 1, 766024278, 675757211, 1, 1974219674, 2147483647, 1, 1841130038, 1951476385, 2147483647, 1, 1757384483, 2147483647, 1, 1, 2147483647, 1, 2105220302, 1, 1090711074)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(136436887, 1, 2147483647, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(789235937)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 528957612, 2147483647, 2147483647, 1983872658, 1, 1, 2147483647, 88171596, 234687542, 1645637322, 1, 1, 1, 168999731, 231330721, 2147483647)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(2147483647, 173588675, 1524867677, 1, 555351990, 2147483647, 1075773089, 870566568, 2147483647, 765187971, 1867625420, 37307120, 1772983173, 1, 1, 438783907, 1155945337, 992303410, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(1, 891833806, 2125061785, 142703108, 1, 1, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(2147483647, 1, 1084867888, 1860004869, 1, 2056988016, 1868872103, 1402646139)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(378216886, 999357941, 1568756420, 1717477872, 1, 1, 382959318, 587557418, 1549232033, 1, 2147483647, 1, 2147483647, 1, 1292689089, 1, 1, 1, 1)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(2147483647, 1622327476, 1, 1556365831, 1110050071, 1, 2120450871, 1, 2147483647, 10735455, 2092609968, 1, 926303909, 742275113, 1007880171, 1679635231, 496892038)), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List()), Nu(higherkindness.droste.GCoalgebra@5d801bc9, List(845669941, 728361666, 1784236896, 2147483647, 1602167429, 1, 1, 1300627525, 1, 1)))
[info] > Exception: java.lang.StackOverflowError: null

[error] (tests / Test / test) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 135 s (02:15), completed Sep 5, 2022, 6:15:31 AM

Basis instance for cats.free.Free

Hi there!

I have a use-case requiring an instance of Basis for cats.free.Free. I see that one for Cofree is already included (#28). Would you welcome a PR adding an instance for Free?

Ambiguous implicits when using project syntax

In trying to upgrade from 0.6 to 0.7, I was using _.project in various places to unwrap a single level of a pattern functor - that now fails with errors like:

[error]  found   : x$3.type (with underlying type datum.patterns.data.Data)
[error]  required: ?{def project: ?}
[error] Note that implicit conversions are not applicable because they are ambiguous:
[error]  both method toProjectSyntaxOps in trait ProjectSyntax of type [F[_], T](t: T)(implicit PFT: higherkindness.droste.Project[F,T])higherkindness.droste.syntax.ProjectSyntax.ProjectOps[F,T]
[error]  and method toFoldableProjectSyntaxOps in trait ProjectSyntax of type [F[_], T](t: T)(implicit PFT: higherkindness.droste.Project[F,T], implicit FF: cats.Foldable[F])higherkindness.droste.syntax.ProjectSyntax.ProjectFoldableOps[F,T]
[error]  are possible conversion functions from x$3.type to ?{def project: ?}

Looking at the trait ProjectSyntax, perhaps it could be resolved using the LowPriorityImplicitTrait trick to make one of the implicit take precedence over the other?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.