-- grab an item from PSQueue with minimal priority
-- and update priority of its neighbours
extractMin :: Graph -> Distance -> (Binding Vertex Priority, Queue) -> ((Vertex, Cost, Vertex), Queue)
extractMin graph dist (destination :-> Priority cost source, queue) = ((destination, cost, source), relaxList queue adj)
  where
    adj = [(neighbour, Priority (cost + dist destination neighbour) destination) | neighbour <- graph destination]

-- update priority of a given key in PSQueue
extractMin :: Graph -> Distance -> (Binding Vertex Priority, Queue) -> ((Vertex, Cost, Vertex), Queue)
extractMin graph dist (destination :-> Priority cost source, queue) = ((destination, cost, source), relaxList queue adj)
  where
    adj = [(neighbour, Priority (cost + dist destination neighbour) destination) | neighbour <- graph destination]

-- update priority of a given key in PSQueue
extractMin graph dist (destination :-> Priority cost source, queue) = ((destination, cost, source), relaxList queue adj)
  where
    adj = [(neighbour, Priority (cost + dist destination neighbour) destination) | neighbour <- graph destination]

-- update priority of a given key in PSQueue