Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Christophe Raffalli <raffalli@cs.chalmers.se>
To: caml-list@pauillac.inria.fr
Subject: Relation between functors and polymorphism
Date: Wed, 3 Apr 1996 11:59:24 +0200 (MET DST)	[thread overview]
Message-ID: <199604030959.LAA25846@lips.cs.chalmers.se> (raw)



Hi,

I have a question that arise in the following circonstances:
I modified the Hashtbl library to make it a function taking a "key structure"
containing a type "key" a function "hash : key -> int" and a function "eq :
key -> key -> bool". Then I wondered how I could use the polymorphic hash and
equality functions to recover the original polymorphic Hashtbl structure.

You can generalize the question to:

What is the relation between a functor that only depends on one type (or more)
like

module A (B : sig type t end) = struct
  type u = Some of B.t | None

  let read = function
    Some x -> x
  | None -> raise Not_found
end

and a polymorphic structure like

module A' = struct
  type 'a u = Some of 'a | None

  let read = function
    Some x -> x
  | None -> raise Not_found
end

They look isomorphic ?

---

You can easely go from A' to A (This is quite verbose but you don't have to
rewrite the types or functions definitions):

module A (B : sig type t end) = struct
  type u = B.t A'.u

  let read = (A'.read : u -> B.t)
end


But how can you reconstruct A' from A without rewriting the type or function
definitions. Is this impossible ?

----
Christophe Raffalli
Dept. of Computer Sciences
Chalmers University of Technology

URL: http://www.logique.jussieu.fr/www.raffalli





             reply	other threads:[~1996-04-03 17:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-04-03  9:59 Christophe Raffalli [this message]
1996-04-04  9:09 ` Wolfgang Lux

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=199604030959.LAA25846@lips.cs.chalmers.se \
    --to=raffalli@cs.chalmers.se \
    --cc=caml-list@pauillac.inria.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