From: Wolfgang Lux <lux@heidelbg.ibm.com>
To: Christophe Raffalli <raffalli@cs.chalmers.se>
Cc: caml-list@pauillac.inria.fr
Subject: Re: Relation between functors and polymorphism
Date: Thu, 04 Apr 96 10:09:15 +0100 [thread overview]
Message-ID: <9604040809.AA38159@idse.heidelbg.ibm.com> (raw)
In-Reply-To: (Your message of Wed, 03 Apr 96 11:59:24 O.) <199604030959.LAA25846@lips.cs.chalmers.se>
>
>
> Hi,
>
> [...]
>
> 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 ?
No they are not isomorphic. The type A(B).u (for whatever module B the
matches the signature sig type t end), is monomorphic, while the type
'a A'.u is polymorphic.
>
> ---
>
> 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
>
This is obviously possible, as you now consider the polymorphic type
'a A'.u for one concrete type B.t.
>
> But how can you reconstruct A' from A without rewriting the type or function
> definitions. Is this impossible ?
>
Yes. Once you have lost polymorphism by applying the type schme of
A'.u to a type B.t, the resulting type no longer has a free type
variable you cou generalize over.
Regards
Wolfgang
----
Wolfgang Lux
WZH Heidelberg, IBM Germany Internet: lux@heidelbg.ibm.com
+49-6221-59-4546 VNET: LUX at HEIDELBG
+49-6221-59-3500 (fax) EARN: LUX at DHDIBMIP
prev parent reply other threads:[~1996-04-05 8:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-04-03 9:59 Christophe Raffalli
1996-04-04 9:09 ` Wolfgang Lux [this message]
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=9604040809.AA38159@idse.heidelbg.ibm.com \
--to=lux@heidelbg.ibm.com \
--cc=caml-list@pauillac.inria.fr \
--cc=raffalli@cs.chalmers.se \
/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