Subsumption in partially ordered sets

Graham Klyne GK at ninebynine.org
Tue Nov 18 10:50:30 EST 2003


At 09:14 18/11/03 +1300, Tom Pledger wrote:
>Graham Klyne writes:
>  :
>  | Below is some code I have written, which works, but I'm not sure
>  | that it's especially efficient or elegant.  Are there any published
>  | Haskell libraries that contain something like this?
>
>Hi.
>
>Partially ordered sets are in cahoots with lattices, so you may be
>interested in http://www.cse.ogi.edu/~mpj/pubs/lattices.html .

That might be interesting... is full paper available online?  (I don't have 
easy access to a serious technical library.)

>And here's some off-the-cuff feedback...
>
>How about using Maybe Ordering, instead of a new data type?
>(As in http://www.mail-archive.com/haskell@haskell.org/msg05635.html)

Duh.  That sounds like an excellent idea - I knew there was a reason for 
posing dumb questions like these!

>Instead of hard-wiring Maybe into the element type in dropSubsumed,
>how about passing in a partial comparison function?
>
>     dropSubsumedBy :: (a -> a -> Maybe Ordering) -> [a] -> [a]

Yes, I agree that would be neater.

(Though I was aware that this code was too specialized in many ways.  I 
have noticed that it's often easier (for me) to code for a specific 
situation and then generalize the resulting code, than to go immediately 
for the general case.  Haskell seems to be particularly well suited to 
factoring out the type-specific bits in this way, I think because it's 
often easy to parameterize any piece of code as a higher order function.)

Thanks for your insights!

#g


------------
Graham Klyne
For email:
http://www.ninebynine.org/#Contact



More information about the Haskell-Cafe mailing list