I would like to solve this problem in Clean (a language very similar to Haskell):
There is a class Node t
, with two instances: instance Node EdgeList
and instance Node Adjacency
. I would like to create a Graph, which is an array or list of Nodes.
The definition of the Graph
is:
class Graph t1 t2 | Node t2 where
resetGraph :: (t1 t2) -> (t1 t2)
graphSize :: (t1 t2) -> Int
...
I would like to write the instances. One with array, and one with list. First, I tried with list, but I get an error: t2 not defined
instance Graph [t1] t2 | t2 t1 where
(resetGraph) :: [t1] -> [t1]
(resetGraph) x = []
...
It will be called for example like this: resetGraph listAdj
where listAdj is a list of Adjacency
Nodes
If I just write: instance Graph [tt] tt
then I get this error: Error: this type variable occurs more than once in an instance type
.