caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Eric C. Cooper" <ecc@cmu.edu>
To: caml-list@inria.fr
Subject: Re: [Caml-list] optional arguments and unification
Date: Tue, 3 Jun 2003 23:23:24 -0400	[thread overview]
Message-ID: <20030604032324.GA5986@ecooper.com> (raw)
In-Reply-To: <4.3.2.7.2.20030603195340.032a40e0@localhost>

On Tue, Jun 03, 2003 at 07:58:19PM -0700, Chris Hecker wrote:
> let f ?opt x = x + 1
> let g x = x + 1
> let h = if true then f else g
> 
> This expression has type int -> int but is here used with type
>   ?opt:'a -> int -> int
> 
> So you have to do this:
> 
> let h = if true then f ?opt:None else g

You could also write:
    let h = if true then (fun x -> f x) else g
or even
    let h = let f x = f x in if true then f else g

-- 
Eric C. Cooper          e c c @ c m u . e d u

-------------------
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:[~2003-06-04  3:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-04  2:58 Chris Hecker
2003-06-04  3:23 ` Eric C. Cooper [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=20030604032324.GA5986@ecooper.com \
    --to=ecc@cmu.edu \
    --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;
as well as URLs for NNTP newsgroup(s).