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

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

Expand Messages
  • Seth J. Fogarty
    Nov 4, 2004
      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).

      --
      Seth Fogarty sfogarty@[gmail.com|rice.edu|livejournal]
      Neep-neep at large AIM: Sorrath
      "I know there are people in this world who do not love their fellow
      human beings - and I hate people like that" --Tom Lehrer.
    • Show all 26 messages in this topic