John Fouhy wrote:
In Haskell, I envisage writing something like:
data ThingCompare = TC Op Field
This wants to be a bit more concrete:
data ThingCompare = TC (a -> a -> Bool) (Thing -> a)
so that you could then have something to execute your comparison thingy:
runTC :: ThingCompare -> Thing -> Thing -> Bool
runTC (TC compare extract) a b = compare (extract a) (extract b)
and construct a value of it:
tcEqFirst = TC (==) first_field
so to compare two Things, you'd do something like this:
runTC tcEqFirst a b
<b
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe