I have the following purescript code:
class Node a where
parentNode :: forall b. (Node b) => a -> b
but when compiling this I get the following error:
A cycle appears in the definition of type synonym Node
Cycles are disallowed because they can lead to loops in the type checker.
Consider using a 'newtype' instead.
I am trying to write a function parentNode
that returns the parent node of a node. The only guarantee for the parent node is that it is also a Node b
.
I do not care what the actual type for b
is.
I am basically trying to say, parentNode
should be a function that returns a value that also implements the Node typeclass. Is something like this possible with type classes or is there some other idiomatic way to do this type of thing?