caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: james woodyatt <jhw@wetware.com>
To: Pixel <pixel@mandrakesoft.com>
Cc: The Trade <caml-list@inria.fr>
Subject: Re: [Caml-list] Is a Cow an Animal?
Date: Thu, 18 Apr 2002 15:57:59 -0700	[thread overview]
Message-ID: <BAABF8E8-531F-11D6-9686-000502DB38F5@wetware.com> (raw)
In-Reply-To: <lybscgmxta.fsf@leia.mandrakesoft.com>

On Thursday, April 18, 2002, at 03:44 PM, Pixel wrote:
>
> well, i don't really understand the """type 'diet energy = int""" stuff.
> but neither is my ocaml's:
>
> # let carrot = new carrot 2 ;;
> # let cow = new cow 10 ;;
> # let _ = cow#feed carrot#energy ;;
>
> # cow#feed;;
> - : [ `E_cow] energy -> cow = <fun>
> # carrot#energy;;
> - : [ `E_rabbit | `E_human] energy = 2
> # (carrot#energy : [ `E_cow ] energy);;
> - : [ `E_cow] energy = 2
>
> what am i missing?

It looks like the 'a energy type is not actually abstract in your trial 
above.  It has to be abstract or the technique doesn't work.

	# carrot#energy;;
	- : [ `E_rabbit | `E_human] energy = 2

Since the type is concrete, it resolves at compile time into an integer, 
and an integer is an integer is an integer.  Try compiling the .cmo file 
from the .ml and .mli files I posted and using the #load directive from 
the top-level.


--
j h woodyatt <jhw@wetware.com>

-------------------
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


  reply	other threads:[~2002-04-18 22:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-17 23:40 Pixel
2002-04-18  2:17 ` John Max Skaller
2002-04-18 10:19   ` Pixel
2002-04-18 12:09     ` Pixel
2002-04-18 12:52       ` Jacques Garrigue
2002-04-18 13:03         ` Pixel
2002-04-18 18:58 ` james woodyatt
2002-04-18 22:44   ` Pixel
2002-04-18 22:57     ` james woodyatt [this message]
2002-04-18 23:31       ` Pixel
2002-04-19  0:21   ` Remi VANICAT
2002-04-19  0:51     ` james woodyatt

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=BAABF8E8-531F-11D6-9686-000502DB38F5@wetware.com \
    --to=jhw@wetware.com \
    --cc=caml-list@inria.fr \
    --cc=pixel@mandrakesoft.com \
    /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;
as well as URLs for NNTP newsgroup(s).