i have a class with a method that returns a function object. the requirements are that the method is arity 0 and its return type is an Option of a Function0 - whose return type is the original return type. for example:
class MyClass {
def f(): Option[Function[A]] = Some(g _)
def g(): Option[Function[A]] = Some(h _)
... goes on and on, eventually returns Some(z _) ...
def z(): Option[Function[A]] = None
}
Due to the recursion, the issue is that the type A is defined as:
type A = Option[Function0[A]]
but since cyclic references are not allowed, it produces the error:
illegal cyclic reference involving type A
i obviously want to avoid defining a different return type for each of the methods, but having a unified return type doesn't seem possible due to the cycle. is there any way to do this? thanks!