caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] a question about Ocaml toplevel behavior
@ 2018-03-10 17:55 Matej Košík
  2018-03-11 13:30 ` Matej Košík
  0 siblings, 1 reply; 8+ messages in thread
From: Matej Košík @ 2018-03-10 17:55 UTC (permalink / raw)
  To: caml-list

Hi,

I've noticed that Ocaml (4.06.1) toplevel displays:

  <abstr>

instead of the actual term even if the value does not belong to an abstract data type.

Question #1: Is this the expected behavior?

My interaction with Ocaml toplevel was:

  # #load "misc_.cmo";;
  # #load "warnings_.cmo";;
  # #load "config_.cmo";;
  # #load "identifiable_.cmo";;
  # #load "numbers_.cmo";;
  # #load "arg_helper_.cmo";;
  # #load "clflags_.cmo";;
  # #load "location_.cmo";;
  # #load "docstrings_.cmo";;
  # #load "syntaxerr_.cmo";;
  # #load "ast_helper_.cmo";;
  # #load "longident_.cmo";;
  # #load "parser_.cmo";;
  # #load "lexer_.cmo";;
  # "foo" |> Lexing.from_string |> Parser_.implementation Lexer_.token_with_comments;;
    - : Parsetree_.structure =
  [{Parsetree_.pstr_desc =
     Parsetree_.Pstr_eval
      ({Parsetree_.pexp_desc = Parsetree_.Pexp_ident <abstr>;
        pexp_loc = <abstr>; pexp_attributes = []},
      []);
    pstr_loc = <abstr>}]

In the last response above, "<abstr>" appears twice.
In my opinion, in each case the actual term should have been printed.
The modules I have loaded where copied from Ocaml compiler with some α-conversions to avoid messages about duplicate interfaces.

What is strange is when I run a few other (dummy) commands:

  let Parsetree_.Pstr_eval (a,_) = ("foo" |> Lexing.from_string |> Parser_.implementation Lexer_.token_with_comments |> List.hd).pstr_desc;;
  let _ = Longident_.parse "foo.bar.baz";;
  Location_.none;;

then the original command:

  "foo" |> Lexing.from_string |> Parser_.implementation Lexer_.token_with_comments;;

is printed the expected way, i.e. without "<abstr>":

  [{Parsetree_.pstr_desc =
     Parsetree_.Pstr_eval
      ({Parsetree_.pexp_desc =
         Parsetree_.Pexp_ident
          {Parsetree_.Asttypes.txt = Parsetree_.Longident.Lident "foo";
           loc =
            {Parsetree_.Asttypes.Location.loc_start =
              {Lexing.pos_fname = ""; pos_lnum = 1; pos_bol = 0; pos_cnum = 0};
             loc_end =
              {Lexing.pos_fname = ""; pos_lnum = 1; pos_bol = 0; pos_cnum = 3};
             loc_ghost = false}};
        pexp_loc =
         {Parsetree_.Asttypes.Location.loc_start =
           {Lexing.pos_fname = ""; pos_lnum = 1; pos_bol = 0; pos_cnum = 0};
          loc_end =
           {Lexing.pos_fname = ""; pos_lnum = 1; pos_bol = 0; pos_cnum = 3};
          loc_ghost = false};
        pexp_attributes = []},
      []);
    pstr_loc =
     {Parsetree_.Asttypes.Location.loc_start =
       {Lexing.pos_fname = ""; pos_lnum = 1; pos_bol = 0; pos_cnum = 0};
      loc_end =
       {Lexing.pos_fname = ""; pos_lnum = 1; pos_bol = 0; pos_cnum = 3};
      loc_ghost = false}}]

Question 2: Does this make sense?
            Can the same value by printed by Ocaml toplevel sometimes as "<abstr>" and sometimes in the ordinary fashion?

Thanks in advance for the advice!

Matej

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-03-12  9:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-10 17:55 [Caml-list] a question about Ocaml toplevel behavior Matej Košík
2018-03-11 13:30 ` Matej Košík
2018-03-11 15:06   ` Nicolás Ojeda Bär
2018-03-11 15:51     ` Matej Košík
2018-03-11 19:17       ` Nicolás Ojeda Bär
2018-03-12  8:44         ` Matej Košík
2018-03-12  8:50     ` Jacques Garrigue
2018-03-12  9:09       ` Matej Košík

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