From: james woodyatt <jhw@wetware.com>
To: The Trade <caml-list@inria.fr>
Subject: Re: [Caml-list] Re: findlib-0.8.1 and ocaml-3.07+beta1
Date: Thu, 24 Jul 2003 18:52:07 -0700 [thread overview]
Message-ID: <98E41980-BE42-11D7-AF49-000393BA7EBA@wetware.com> (raw)
In-Reply-To: <3F2087BF.5080903@1969.ws>
On Thursday, Jul 24, 2003, at 18:28 US/Pacific, Karl Zilles wrote:
> james woodyatt wrote:
>> I'm specifically excited about the polymorphic generalization of
>> covariant parts of expansive expressions.
>
> I read about this in the changes document, but I'm unable to wrap my
> head around it.
>
> > For instance, if f: unit -> 'a list, "let x = f ()"
> > gives "x" the generalized type forall 'a. 'a list, instead of '_a
> list
> > as before.
>
> Can someone simplify this for me? Under what circumstances would this
> be useful?
Sure. I see it with functors. Consider the following example:
# module type X = sig
type +'a t
val f: unit -> 'a t
end;;
This is a module type I plan to use as the input to a functor. The top
responds with this following:
module type X = sig type +'a t val f : unit -> 'a t end
So, imagine you want to write a functor like so:
# module Y(X: X) = struct
let x = X.f ()
end;;
Here's what the 3.06 top-level says is the type of that module:
module Y : functor (X : X) -> sig val x : '_a X.t end
Here's what the 3.07+beta1 version says:
module Y : functor (X : X) -> sig val x : 'a X.t end
This is so much better. In the 3.06 case, I get a module whose type
isn't complete yet. In the 3.07+beta1 case, I get a module whose type
is complete. With 3.06, I have to write 'x' as a function that returns
a constructed object every time I call it. With 3.07+beta1, I can
write 'x' as a value that gets constructed once when the functor is
called.
--
j h woodyatt <jhw@wetware.com>
that's my village calling... no doubt, they want their idiot back.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2003-07-25 1:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1059053910.4721.22.camel@athene>
2003-07-25 0:27 ` james woodyatt
2003-07-25 1:28 ` Karl Zilles
2003-07-25 1:52 ` james woodyatt [this message]
2003-07-25 16:27 ` pjd
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=98E41980-BE42-11D7-AF49-000393BA7EBA@wetware.com \
--to=jhw@wetware.com \
--cc=caml-list@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