Version française
Home     About     Download     Resources     Contact us    
Browse thread
make[1]: warning: Clock skew detected. Your build may be incomplete.
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Diego Olivier Fernandez Pons <Diego.FERNANDEZ_PONS@e...>
Subject: Equality/Hashtable for functions (inline help feature)
    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