On Fri, Apr 24, 2009 at 19:49, Edward Kmett <[email protected]> wrote:
> On Fri, Apr 24, 2009 at 5:11 PM, Denis Bueno <[email protected]> wrote:
>> Is there an Ord instance that can be dynamically changed in this way?
>>
>> My first idea is something like this:
>>
>>    data CompareRecord = CR{ rCompare :: Record -> Record -> Ordering,
>> unCR :: Record }
>>    instance Ord CompareRecord where
>>        compare (CR cmp x) (CR _ y) = cmp x y
>>
>> where the rCompare field would be a function that is based on the
>> flags passed to the command-line problem.  But this has an ugly
>> asymmetry.  Does anyone have any other ideas?
>
> You can make a safer 'CompareRecord' using 'reflection' from hackage:

This is what I ended up doing and it worked out great.  Thanks for the
suggestion.

                              Denis
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to