
You can try Data.Set.minView.
http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-Set.html
Cheers,
JP.
On 12/11/06, Henning Thielemann
I'm using Set for algorithms which work this way: while the set is non-empty choose an element from the set do something with that element remove the element and some more that depend on it
However when I code this with Set.null and Set.findMin, I run into the same trouble like with List.null and List.head, namely Set.findMin is a partial function. I like to have a function like choose :: Set a -> Maybe a choose set = toMaybe (not (Set.null set)) (Set.findMin set)
toMaybe :: Bool -> a -> Maybe a toMaybe False _ = Nothing toMaybe True x = Just x
in Data.Set.
Opinions? _______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries