
13 Mar
2007
13 Mar
'07
11:20 p.m.
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