Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Angela Zhu" <angela22.zhu@gmail.com>
To: "Jonathan T Bryant" <jtbryant@valdosta.edu>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Type issue
Date: Fri, 23 Nov 2007 06:33:52 -0600	[thread overview]
Message-ID: <f82e818a0711230433w40917fa5jc5a99a1b5d96bf8a@mail.gmail.com> (raw)
In-Reply-To: <2921298.1195790493072.JavaMail.jtbryant@valdosta.edu>

I think it is because you have
"if  f c then ... else ..."
     ---

this restrict "f c" must be bool, thus 'a is bool.


On Nov 22, 2007 10:01 PM, Jonathan T Bryant <jtbryant@valdosta.edu> wrote:
> List,
>
> I don't understand the following typing:
>
> # type 'a t = Cond of bool t * 'a t * 'a t | Value of 'a;;
> type 'a t = Cond of bool t * 'a t * 'a t | Value of 'a
>
> # let rec f t = match t with
>       Cond (c,t,e) -> if f c then f t else f e
>     | Value x -> x
>   ;;
> val f : bool t -> bool = <fun>
>
> I don't understand why f isn't of type 'a t -> 'a.  I understand that f
> is applied to a bool t, but I would think that that would just be a
> particular instantiation of 'a, not enough to fully determine its type.
>
> --Jonathan Bryant
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>



-- 
Regards,
Angela Zhu
------------------------------------------
Dept. of CS, Rice University
http://www.cs.rice.edu/~yz2/
------------------------------------------


      parent reply	other threads:[~2007-11-23 12:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-23  4:01 Jonathan T Bryant
2007-11-23  8:26 ` [Caml-list] " Andrej Bauer
2007-11-23  9:27   ` Oliver Bandel
2007-11-23  8:30 ` Florian Weimer
2007-11-23  9:14 ` Alain Frisch
2007-11-23 13:38   ` Arnaud Spiwack
2007-11-23 13:44     ` Vincent Aravantinos
2007-11-23  9:33 ` Oliver Bandel
2007-11-23 12:33 ` Angela Zhu [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=f82e818a0711230433w40917fa5jc5a99a1b5d96bf8a@mail.gmail.com \
    --to=angela22.zhu@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=jtbryant@valdosta.edu \
    /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