precog / matryoshka

Generalized recursion schemes and traversals for Scala.
Apache License 2.0
811 stars 87 forks source link

README should mention the need to import fixpoint types #59

Closed klaeufer closed 7 years ago

klaeufer commented 7 years ago

To use Fix etc., it is insufficient to import only

import matryoshka._
import matryoshka.implicits._

An explicit import of matryoshka.data.Fix etc. is required. It would be helpful if the README said so more prominently; right now, this is buried in the eval example.

sellout commented 7 years ago

Good catch. I’m working on writing some tut docs to replace the bulk of the README, and I’ll make sure to address this there.

One other thing I recommend is to avoid using specific fixed-point types as much as possible.

// Prefer
def foo[T, F[_]: Functor](fa: F[T])(implicit T: Recursive.Aux[T, F]): T
// over
def foo[F[_]](fa: F[Fix[F]]): Fix[F]

as it makes the algebra much more general. (This is something else the new docs will go into.) And there are some upcoming changes to scalac that will reduce the noise involved.

klaeufer commented 7 years ago

@sellout I highly appreciate this generality, but the target audience for my examples are juniors, seniors, and master's students in CS and SE. If I can get them to understand functors, simple type-level recursion, and cata/ana, then that's a considerable success. 😄

klaeufer commented 7 years ago

Hi again, you might also want to mention in the README that instances of Delay[Equal, F] and Delay[Show, F] are required for the recursive types over F to support Equal and Show.

(I hope this level of feedback is useful.)

sellout commented 7 years ago

Yes, thank you – this is extremely useful feedback. I find that since I wrote most of this code, I gloss over so much that is necessary in understanding it (and which I struggled to understand when I was first dealing with it). So I am very happy that you’ve opened these issues.