caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Diego Olivier Fernandez Pons <Diego.FERNANDEZ_PONS@etu.upmc.fr>
To: caml-list@inria.fr
Subject: Equality/Hashtable for functions (inline help feature)
Date: Wed, 6 Sep 2006 19:50:57 +0200 (DST)	[thread overview]
Message-ID: <Pine.A41.4.44.0609061934150.524484-100000@ibm1> (raw)
In-Reply-To: <44FF033C.3040405@abc.se>

    Bonjour,

I would like to write a (non intrusive) inline help feature for some
modules I wrote, that would look like

# help MyModule.is_prime;
- : string = "is_prime : int -> bool computes if an integer given as a
parameter is prime"
# help MyModule.probabilistic_is_prime;
- : string = "..."

I can write a function of type 'a -> string which computes the hash key of
the parameter and returns the string associated in a table, but I cannot
do a physical equality based desambigusation for collision since the
equality is typed

let
   f = function x -> x + 1 and
   g = function x -> x + 2
in (f == f, f == g)
- : bool * bool = (true, false)

let
   f = function x -> x + 1 and
   g = fun x y -> x + y
in (f == f, f == g)
This expression has type int -> int -> int but is here used with type int
-> int

Does anyone know how I could circumvent this problem ?

        Diego Olivier


  reply	other threads:[~2006-09-06 17:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-06 13:36 make[1]: warning: Clock skew detected. Your build may be incomplete Mattias Waldau
2006-09-06 15:15 ` [Caml-list] " skaller
2006-09-06 16:01 ` Igor Peshansky
2006-09-06 17:19   ` Mattias Waldau
2006-09-06 17:50     ` Diego Olivier Fernandez Pons [this message]
2006-09-07  0:19       ` [Caml-list] Equality/Hashtable for functions (inline help feature) Jacques Garrigue
2006-09-07 10:31         ` Diego Olivier Fernandez Pons
2006-09-07  0:23     ` [Caml-list] make[1]: warning: Clock skew detected. Your build may be incomplete Jacques Garrigue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.A41.4.44.0609061934150.524484-100000@ibm1 \
    --to=diego.fernandez_pons@etu.upmc.fr \
    --cc=caml-list@inria.fr \
    --cc=diego-olivier.fernandez-pons@cicrp.jussieu.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).