A simple Haskell instance question

I am trying to use different data structures to implement the Prim algorithm. So I made a class for abstraction, what I want to do:

class VertexContainer a where
  contains :: a -> Vertex -> Bool
  insert :: a -> WeightedEdge -> a
  numVertices :: a -> Int

Now I want to use a bunch (of Data.Heap) as a container of vertices. But I can’t have my syntax defining my life. As you can see from the declaration insert, a container can only contain WeightedEdges, which are a data type. So I tried:

instance VertexContainer (Heap MinPolicy WeightedEdge) where
  contains _ _ = True

This tells me about an illegal synonym. I tried different permutations and none of them seem to work. Can anybody help me?

+3
source share
2 answers

, , , , , TypeSynonymInstances. , -XTypeSynonymInstances .

+6

, . . , , .

+1

All Articles