I think the previous code for Coend was incorrect. The previous code was in no way different from the code for trait PolyFunction1, i.e. for End. The Coend must contain an existential quantifier. An existential quantifier is encoded in Scala as a case class with an extra type parameter. An universal quantifier is encoded as a trait with a method having a type parameter.
I think the previous code for
Coend
was incorrect. The previous code was in no way different from the code fortrait PolyFunction1
, i.e. forEnd
. TheCoend
must contain an existential quantifier. An existential quantifier is encoded in Scala as a case class with an extra type parameter. An universal quantifier is encoded as a trait with a method having a type parameter.