On Fri, Apr 24, 2009 at 19:49, Edward Kmett wrote:
> On Fri, Apr 24, 2009 at 5:11 PM, Denis Bueno 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,
On Fri, Apr 24, 2009 at 5:11 PM, Denis Bueno wrote:
> Hi all,
>
> Suppose I have the following interface to a sorting function:
>
>sort :: (Ord a) => [a] -> IO [a] -- sort large, on-disk array of records
>
> but I don't have a sortBy where you can simply pass a compare function.
>
> Wrapped a
Denis Bueno wrote:
Hi all,
Suppose I have the following interface to a sorting function:
sort :: (Ord a) => [a] -> IO [a] -- sort large, on-disk array of records
but I don't have a sortBy where you can simply pass a compare function.
Why don't you have sortBy?
Wrapped around this is a
Denis Bueno wrote:
The problem here is that the order is fixed. Statically. I can't
change it at runtime based on flags. (Right? Unless I'm missing
something)
That is right. It might or might not be a problem in your specific case.
sortBy :: (a -> a -> Ord) -> [a] -> IO [a]
sortBy cmp
Hi Denis,
Denis Bueno wrote:
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?
Here's a solution that is more symmetrical but not necessarily prettier:
newtype Wrap =
On Fri, Apr 24, 2009 at 15:22, Martijn van Steenbergen
wrote:
> Hi Denis,
>
> Denis Bueno wrote:
>>
>> 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?
>
> Here's a
Hi all,
Suppose I have the following interface to a sorting function:
sort :: (Ord a) => [a] -> IO [a] -- sort large, on-disk array of records
but I don't have a sortBy where you can simply pass a compare function.
Wrapped around this is a command-line program which should allow the
user to