fgl icon indicating copy to clipboard operation
fgl copied to clipboard

Introduce lookup options when inserting node in a NodeMap

Open nobrakal opened this issue 6 years ago • 5 comments

This is a try to fix #72 .

The main new function is mkLookupNode, which is mkNode plus a Boolean saying if the node was already present.

I also added a member-like function.

nobrakal avatar May 12 '18 11:05 nobrakal

I'm wondering whether it might be worth defining a new type isomorphic to Bool to make it clear what the result it (does True mean "added in" or "already present"?).

ivan-m avatar May 12 '18 12:05 ivan-m

It might worth it, you are right. Seems a bit overkill for two functions. I don't know if lookup counter-part functions can be made/are interesting in NodeMap

I am also wondering if a direct lookup version of insNode and maybe insEdge were interesting in the Graph module... They can be easily optimized in PatriciaTree

nobrakal avatar May 12 '18 13:05 nobrakal

Is there anything preventing this from being pulled? I'm looking for this exact functionality.

runeksvendsen avatar Dec 20 '18 13:12 runeksvendsen

The only thing I'd like to add is that -- while we're at it -- it would be nice to also have the corresponding monadic versions of e.g. lookupNode:

lookupNodeM :: (Ord a) => a -> NodeMapM a b g (Maybe Node).

runeksvendsen avatar Dec 20 '18 16:12 runeksvendsen

I also need this function :)

cdupont avatar Oct 02 '21 19:10 cdupont

Is there still interest in this functionality? If so, I will merge this PR.

athas avatar Oct 18 '22 10:10 athas

This is useful for quickly getting nodes from the label set.

Montmorency avatar Jan 18 '24 13:01 Montmorency