caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain Frisch <frisch@clipper.ens.fr>
To: Rolf Wester <wester@ilt.fhg.de>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Sample code doesn't work
Date: Mon, 16 Jul 2001 17:51:31 +0200 (MET DST)	[thread overview]
Message-ID: <Pine.GSO.4.04.10107161749450.12110-100000@clipper.ens.fr> (raw)
In-Reply-To: <3B5327AF.24111.5E50BF6@localhost>

On Mon, 16 Jul 2001, Rolf Wester wrote:

> let rec make_account wert0 = 
>   let wert = wert0 in
>   let add wert_ =
>     make_account (wert+.wert_)
>   in   
>   let sub wert_ =
>     make_account (wert-.wert_)
>   in 
>   let get () = 
>     wert 
>   in
>   (add, sub, get);;
> 
> When trying to evaluate this I get the error message:
> 
> This expression has type
>   (float -> 'a * 'b * 'c) * (float -> 'a * 'b * 'c) * (unit -> float)
> but is here used with type 'a * 'b * 'c
> 
> How can I make this work?

You need recursive types to be able to unify these two type
expressions. It is often the case when you want, as in this
example, simulate the object paradigm.

Just add the -rectypes switch to the toplevel/compiler command line.


-- 
  Alain Frisch

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


      reply	other threads:[~2001-07-16 15:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-16 15:43 Rolf Wester
2001-07-16 15:51 ` Alain Frisch [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=Pine.GSO.4.04.10107161749450.12110-100000@clipper.ens.fr \
    --to=frisch@clipper.ens.fr \
    --cc=caml-list@inria.fr \
    --cc=wester@ilt.fhg.de \
    /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).