It may be better not to reimplement priority queues and use existing one instead like: https://hackage.haskell.org/package/psqueues