Welcome! Got a question? Do you have -Ypartial-unification turned on? Other FAQs: http://typelevel.org/cats/faq.html
F ~> G
is an alias for FunctionK[F,G]
which is a function from F[A]
to G[A]
for all A
.
F
needs to be a functor or something.
cgntrn
Sorry for taking so much of your time. I just have one more question.
Do I need to create a new algebra where I manually rewrite each function?
Such as:
abstract class A[F[_]: Applicative] {
self =>
def f(i: Int) = i.pure[F]
def mapK[G[_]: Applicative](fk: F ~> G): A[G] = new A[G] {
override def f(i: Int) = fk(self.f(i))
}
}
Is there a better way?
https://github.com/getnelson/quiver
http://www.scala-graph.org/
^ those are the two I know of off hand
cgntrn
Is there any way to define an instance of an algebra for every subtype of a sealed trait and derive an instance of the topmost trait?
I'd like to define an algebra for L and R of
sealed trait TopMost
class L extends TopMost
class R extends TopMost
and freely derive that algebra for TopMost.
Is this possible?