See my snippet below. I have a pretty good idea what the error is, but I wonder whether there is an easy way to query a PSQ using underscores when the key is a tuple. At least it looks very tempting :D.
main :: IO()
main = do
time <- getCPUTime
let qTuple = ("mine", 3455, msgs)
let rrq = PSQ.singleton qTuple time
let r = PSQ.lookup ("mine", _, _) rrq
print (r)
Eventually I have messages destined for IPv4 addresses and TCP-Port numbers that need to be de-queued (after a while) in the order of their creation time: (IPv4, tport), (msg, ctime). On the one hand I want to be able to query if there is a queue for any given tuple (IPv4, tport) existing at all and either create such a queue if required or de-queue it a due-time.
If you’re asking whether you can use a syntax like that to look up any tuple that follows that form in a PSQ, the answer is no 🙂 It would be impossible to do that in general for all data structures, after all.
It sounds like you should allocate a unique identifier (is that what the number is?) to each item (stored in the item itself), and key the PSQ on that; then you could have
Maps from the fields you care about indexing on (the string, the integer, or whatever) to the items; after that it’s just another lookup to get the priority. Of course, you’d need at the very least aMapfrom the unique identifiers to the items themselves.(By the way, if these are the same tuples mentioned in your older question, I would suggest using a data type instead of a tuple.)