Version franēaise
Home     About     Download     Resources     Contact us    
Browse thread
Building a Set module for elements of a Map
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Fabrice Marchant <fabricemarchant@f...>
Subject: Building a Set module for elements of a Map
   Hi List !

Please consider a functor F that takes as input the output signature of a Map.

Here is the only way I see to declare a Set module whose elements type are Map.S.key :

module F ( M : Map.S ) = struct  
  module MKeySet =
    Set.Make ( struct type t = M.key let compare = compare end )
end

  The problem is to access the OrderedType that permitted to build the Map M. It seems to have disappeared inside the output Map signature S. So the trial of regeneration :
struct type t = M.key let compare = compare end

  It maybe exists a straightforward signature we could pick somewhere inside Map related modules ?
  Moreover I'm afraid this "Ersatz" of signature based on _Pervasives_.compare is in some cases deficient, because different from original OrderedType of Map elements...

A parallel question for values type :
 how to declare inside F a module MValueSet to accomodate target elements of the input Map ?

Any light ?

Fabrice