caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Diego Olivier Fernandez Pons <Diego.FERNANDEZ_PONS@etu.upmc.fr>
To: Jean-Baptiste Rouquier <jrouquie@ens-lyon.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] getting the type of a polymorphic data ?
Date: Fri, 13 Aug 2004 10:59:46 +0200 (DST)	[thread overview]
Message-ID: <Pine.A41.4.44.0408131052480.524432-100000@ibm1> (raw)
In-Reply-To: <1092334731.411bb48b56f4e@mouette.ens-lyon.fr>

    Bonjour,

> # type 'a result = 'a * string;;
> # let new_result (a:'a) description = ((a,description) : 'a result);;
> val new_result : 'a -> string -> 'a result = <fun>
> # let print_int ((a,d): int result) = Printf.printf "%s is %d\n%!" d a;;
> val print_int : int result -> unit = <fun>
> # let print_float = ...
> # let x = new_result 10 "the number of elements in the knapsack";;
> val x : int result = ...
> # print_int x;;
> the number of elements in the knapsack is 10
> - : unit = ()

Here is the problem of this approach

# let complex_computation = fun x y -> x + y
val complex_computation : int -> int -> int = <fun>

let x = simple_computation () and
    y = simple_computation ()

let z = complex_computation x y

Now I what to add a comment to x to print intermediate results and
check the first computation is correct. In your approach, this lifts x
: int on x : int result. But what will then be the type of
complex_computation ?

int result -> int -> int ?
int -> int result -> int ?
int result -> int result -> int ?
int result -> int result -> int result ?


        Diego Olivier

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


  parent reply	other threads:[~2004-08-13  9:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-12 18:18 Jean-Baptiste Rouquier
2004-08-13  8:15 ` Diego Olivier Fernandez Pons
2004-08-13  8:59 ` Diego Olivier Fernandez Pons [this message]
     [not found] <20040812143443.2aba80c1@babasse>
2004-08-12 12:47 ` Diego Olivier Fernandez Pons
     [not found] <Pine.A41.4.44.0408121350120.557174-100000@ibm1>
2004-08-12 12:09 ` Diego Olivier Fernandez Pons
2004-08-12 13:38   ` Damien Doligez
2004-08-12 13:57     ` Diego Olivier Fernandez Pons
2004-08-12 14:13       ` Marcin 'Qrczak' Kowalczyk
2004-08-12 14:26         ` Diego Olivier Fernandez Pons
  -- strict thread matches above, loose matches on Subject: below --
2004-08-06 15:05 Diego Olivier Fernandez Pons

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.A41.4.44.0408131052480.524432-100000@ibm1 \
    --to=diego.fernandez_pons@etu.upmc.fr \
    --cc=caml-list@inria.fr \
    --cc=jrouquie@ens-lyon.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).