caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Documentation challenges for the application of comparison functions
@ 2021-01-02 15:42 Markus Elfring
       [not found] ` <CAHsMTAGtTZ7KaSfUqmPJf6bBmX6uD4==x5U3De66EA7Woq4Hhg@mail.gmail.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Markus Elfring @ 2021-01-02 15:42 UTC (permalink / raw)
  To: caml-list

Hello,

I have taken another look at a few functions of a software library
where comparison functions should be passed.

…
let rec find ~cmp x = function
    Empty -> raise Not_found
  | …

let not_found_default_action ~value ?compare:(cmp=Stdlib.compare) =
    raise Not_found
…


Interface descriptions can be generated then in a known format for OCaml 4.11.1.

…
val find : cmp:('a -> 'b -> int) -> 'a -> ('b, 'c) t -> 'c
val not_found_default_action : value:'a -> ?compare:('b -> 'b -> int) -> 'c
…


Now I find two details interesting for further clarification.

1. The first reference for a comparison function seems to express a need for
   different data types “'a” and “'b” while a single type might be sufficient
   for the comparison function according to the second function.

2. The specification of “Stdlib.compare” looks clear according to the semantics
   for a default parameter in a ML source file while the OCaml arrow representation
   can look more challenging.
   How would you recognise that such a function parameter should be applied
   for comparison calls?

Regards,
Markus

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-04 16:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-02 15:42 [Caml-list] Documentation challenges for the application of comparison functions Markus Elfring
     [not found] ` <CAHsMTAGtTZ7KaSfUqmPJf6bBmX6uD4==x5U3De66EA7Woq4Hhg@mail.gmail.com>
     [not found]   ` <9315a69b-5512-7968-2804-785add2d14ea@web.de>
2021-01-04 12:43     ` Matthew Ryan
2021-01-04 16:33       ` Markus Elfring
2021-01-04 16:33       ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).