On Wednesday, May 17, 2017 at 3:57:44 PM UTC+1, Rupert Smith wrote:
>
> On Wednesday, May 17, 2017 at 11:40:35 AM UTC+1, Rupert Smith wrote:
>>
>> http://package.elm-lang.org/packages/TSFoster/elm-heap/latest
>>
>
> Bugger. This heap implementation does not allow and arbitrary comparison 
> function. It has this:
>
>  by : (a -> comparable) -> Options b -> Options a
>
> But that requires a mapping from the type being compares onto comparable.
>
> If there is an implementation that lets me use a comparison function of 
> type 'a -> a -> Order', that would be better.
>

But internally it does use an 'a -> a -> Order':

type Options a
    = Options
        { order : SortOrder
        , compare : a -> a -> Order
        }

Which it builds by converting an 'a -> comparable' function:

makeCompare : (a -> comparable) -> (a -> a -> Order)
makeCompare fn a b =
    Basics.compare (fn a) (fn b)

Perhaps the author meant to expose Options(..) so users can build their own 
compare function?

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to