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

weird types with apostrophies

Expand Messages
  • Mike Tikiliainen <mt99@doc.ic.ac.uk>
    Hi, I m having problems using the PXP library, but the question is general enough for anybody I guess. In particular, the problem is with a function (OK,
    Message 1 of 2 , Mar 2, 2003
    • 0 Attachment
      Hi,

      I'm having problems using the PXP library, but the question is general
      enough for anybody I guess. In particular, the problem is with a
      function (OK, method but it can easily be a function too)

      method write : Pxp_types.output_stream -> Pxp_types.encoding -> unit

      Well, I saw this type Pxp_types.output_stream and thought to myself -
      "OK, I'll just go look it up in the interface file for Pxp_types, find
      out what I need and use it. Pretty trivial so far.

      Then, I went to have a look at the interface file and found the
      following definition:

      type output_stream =
      [ `Out_buffer of Buffer.t
      | `Out_channel of out_channel
      | `Out_function of (string -> int -> int -> unit)
      ]

      Then, I thought, "what the hell are those apostrophe things in front
      of constructors? Surely they would break because that looks like bad
      syntax". I'm still puzzled and hopefully, someone can tell me what
      they are and how to use them.

      Then I tried some possibilities of what I read in the toploop (with
      Pxp loaded correctly):

      # Pxp_types.'Out_channel stderr;; (* the "normal" apostrophe *)
      Syntax error
      # Pxp_types.`Out_channel stderr;;
      (* the other one at the topleft of the keyboard, just below ESC-key *)
      Syntax error
      # Pxp_types.Out_channel stderr;;
      (* giving up hope, tried without any apostrophies *)
      Unbound constructor Pxp_types.Out_channel

      Hey, I have also googled this issue and found a post on the big-scary
      Caml-list where the guy uses the damned apostophies everywhere and his
      compiler/interpreter seems to be fine with them. The post lives at
      http://caml.inria.fr/archives/200204/msg00022.html

      I guess there's something major I am missing here, so please help.

      'MT` ;)
    • Remi Vanicat
      ... And of course, you I immediately look into the ocaml manual too find where they speak about it ? It s describe into the section 4.2 :
      Message 2 of 2 , Mar 2, 2003
      • 0 Attachment
        "Mike Tikiliainen <mt99@...>" <mt99@...> writes:

        > Hi,
        >
        > I'm having problems using the PXP library, but the question is general
        > enough for anybody I guess. In particular, the problem is with a
        > function (OK, method but it can easily be a function too)
        >
        > method write : Pxp_types.output_stream -> Pxp_types.encoding -> unit
        >
        > Well, I saw this type Pxp_types.output_stream and thought to myself -
        > "OK, I'll just go look it up in the interface file for Pxp_types, find
        > out what I need and use it. Pretty trivial so far.
        >
        > Then, I went to have a look at the interface file and found the
        > following definition:
        >
        > type output_stream =
        > [ `Out_buffer of Buffer.t
        > | `Out_channel of out_channel
        > | `Out_function of (string -> int -> int -> unit)
        > ]
        >
        > Then, I thought, "what the hell are those apostrophe things in front
        > of constructors? Surely they would break because that looks like bad
        > syntax". I'm still puzzled and hopefully, someone can tell me what
        > they are and how to use them.

        And of course, you I immediately look into the ocaml manual too find
        where they speak about it ?
        It's describe into the section 4.2 :
        http://pauillac.inria.fr/caml/ocaml/htmlman/manual006.html

        By the way, there is another difference the [ and ].


        >
        > Then I tried some possibilities of what I read in the toploop (with
        > Pxp loaded correctly):
        >
        > # Pxp_types.'Out_channel stderr;; (* the "normal" apostrophe *)
        > Syntax error
        > # Pxp_types.`Out_channel stderr;;
        > (* the other one at the topleft of the keyboard, just below ESC-key *)
        > Syntax error

        `Out_channel stderr will work.

        (no open needed).


        --
        RĂ©mi Vanicat
        vanicat@labri.u-bordeaux.fr
        http://dept-info.labri.u-bordeaux.fr/~vanicat
      Your message has been successfully submitted and would be delivered to recipients shortly.