Loading ...
Sorry, an error occurred while loading the content.

2743Re: "ocaml_beginners"::[] Re: 'ocaml_beginners'::[] Execution semantics

Expand Messages
  • Martin Jambon
    Nov 4, 2004
    • 0 Attachment
      On Thu, 4 Nov 2004, Seth J. Fogarty wrote:

      > RE: counter example.
      > That was easy enough. Still not sure why
      >
      > # let f1 x = x;;
      > val f1 : 'a -> 'a = <fun>
      > # let f2 x = x;;
      > val f2 : 'a -> 'a = <fun>
      > # let f3 a b c = (a,b,c);;
      > val f3 : 'a -> 'b -> 'c -> 'a * 'b * 'c = <fun>
      > # let example2 a b =
      > let a' = f1 a
      > and b' = f2 b
      > in (fun x -> f3 a' b' x);;
      > val example2 : 'a -> 'b -> 'c -> 'a * 'b * 'c = <fun>
      > # let f = example2 1 2;;
      > val f : '_a -> int * int * '_a = <fun>
      >
      > results in f not being fully polymorphic, but
      > val example1 : 'a -> 'b -> 'c -> 'a * 'b * 'c = <fun>
      > let f = fun x -> example1 1 2 x;;
      > val f : 'a -> int * int * 'a = <fun>
      >
      > Does. It seems to me that I should be able to return a (fun x- >
      > blah), and have it be as polymorphic as possible. (not should in the
      > 'right thing' sense, but should in the 'actual way it works' sense,
      > based on my very poor knowledge of ocaml types and '_a).

      I don't know why it is like this (but I don't want to know :-)
      There are a few paragraphs about this topic in the FAQ if you did not read
      it yet:
      http://caml.inria.fr/FAQ/FAQ_EXPERT-eng.html#variables_de_types_faibles


      Martin
    • Show all 26 messages in this topic