What's meaning of Pexp_ident use in parsetree.mli?
I have this prog parsetreetest.ml:
let ()=
let filename = "test.ml" in
Location.input_name := filename ;
let readhandle = open_in filename in
let buf = Lexing.from_channel readhandle in
Location.init buf filename ;
let ast = Parse.implementation buf in
let pstr_desc=(List.nth ast 0).pstr_desc in
match pstr_desc with
|Pstr_eval (expression,attributes)->
match expression.pexp_desc with
|Pexp_constant constant->
match constant with
|Pconst_integer (const_int,char_option)->
Printf.printf "%s" const_int;
close_in readhandle
If test.ml have only a integer,for example:1,this prog can read it and return Parsetree.
In the parsetree.mli:
and expression_desc =
| Pexp_ident of Longident.t loc
(* x
M.x
*)
| Pexp_constant of constant
(* 1, 'a', "true", 1.0, 1l, 1L, 1n *)
the Pexp_ident is paralleling to Pexp_constant,if I write parsetreetest2.ml:
let ()=
let filename = "test2.ml" in
Location.input_name := filename ;
let readhandle = open_in filename in
let buf = Lexing.from_channel readhandle in
Location.init buf filename ;
let ast = Parse.implementation buf in
let pstr_desc=(List.nth ast 0).pstr_desc in
match pstr_desc with
|Pstr_eval (expression,attributes)->
match expression.pexp_desc with
|Pexp_ident loc->
match loc with
|Lident l->
Printf.printf "%s" l;
close_in readhandle
in test2.ml I write x,as the parsetree.mli example show me,then compiler with ocamlbuild,which used to compile parsetreetest.ml success,got error:
File "parsetreetest2.ml", line 14, characters 7-13:
Error: Unbound constructor Lident
I don't know why I can't do this,thanks!
ocaml
add a comment |
I have this prog parsetreetest.ml:
let ()=
let filename = "test.ml" in
Location.input_name := filename ;
let readhandle = open_in filename in
let buf = Lexing.from_channel readhandle in
Location.init buf filename ;
let ast = Parse.implementation buf in
let pstr_desc=(List.nth ast 0).pstr_desc in
match pstr_desc with
|Pstr_eval (expression,attributes)->
match expression.pexp_desc with
|Pexp_constant constant->
match constant with
|Pconst_integer (const_int,char_option)->
Printf.printf "%s" const_int;
close_in readhandle
If test.ml have only a integer,for example:1,this prog can read it and return Parsetree.
In the parsetree.mli:
and expression_desc =
| Pexp_ident of Longident.t loc
(* x
M.x
*)
| Pexp_constant of constant
(* 1, 'a', "true", 1.0, 1l, 1L, 1n *)
the Pexp_ident is paralleling to Pexp_constant,if I write parsetreetest2.ml:
let ()=
let filename = "test2.ml" in
Location.input_name := filename ;
let readhandle = open_in filename in
let buf = Lexing.from_channel readhandle in
Location.init buf filename ;
let ast = Parse.implementation buf in
let pstr_desc=(List.nth ast 0).pstr_desc in
match pstr_desc with
|Pstr_eval (expression,attributes)->
match expression.pexp_desc with
|Pexp_ident loc->
match loc with
|Lident l->
Printf.printf "%s" l;
close_in readhandle
in test2.ml I write x,as the parsetree.mli example show me,then compiler with ocamlbuild,which used to compile parsetreetest.ml success,got error:
File "parsetreetest2.ml", line 14, characters 7-13:
Error: Unbound constructor Lident
I don't know why I can't do this,thanks!
ocaml
add a comment |
I have this prog parsetreetest.ml:
let ()=
let filename = "test.ml" in
Location.input_name := filename ;
let readhandle = open_in filename in
let buf = Lexing.from_channel readhandle in
Location.init buf filename ;
let ast = Parse.implementation buf in
let pstr_desc=(List.nth ast 0).pstr_desc in
match pstr_desc with
|Pstr_eval (expression,attributes)->
match expression.pexp_desc with
|Pexp_constant constant->
match constant with
|Pconst_integer (const_int,char_option)->
Printf.printf "%s" const_int;
close_in readhandle
If test.ml have only a integer,for example:1,this prog can read it and return Parsetree.
In the parsetree.mli:
and expression_desc =
| Pexp_ident of Longident.t loc
(* x
M.x
*)
| Pexp_constant of constant
(* 1, 'a', "true", 1.0, 1l, 1L, 1n *)
the Pexp_ident is paralleling to Pexp_constant,if I write parsetreetest2.ml:
let ()=
let filename = "test2.ml" in
Location.input_name := filename ;
let readhandle = open_in filename in
let buf = Lexing.from_channel readhandle in
Location.init buf filename ;
let ast = Parse.implementation buf in
let pstr_desc=(List.nth ast 0).pstr_desc in
match pstr_desc with
|Pstr_eval (expression,attributes)->
match expression.pexp_desc with
|Pexp_ident loc->
match loc with
|Lident l->
Printf.printf "%s" l;
close_in readhandle
in test2.ml I write x,as the parsetree.mli example show me,then compiler with ocamlbuild,which used to compile parsetreetest.ml success,got error:
File "parsetreetest2.ml", line 14, characters 7-13:
Error: Unbound constructor Lident
I don't know why I can't do this,thanks!
ocaml
I have this prog parsetreetest.ml:
let ()=
let filename = "test.ml" in
Location.input_name := filename ;
let readhandle = open_in filename in
let buf = Lexing.from_channel readhandle in
Location.init buf filename ;
let ast = Parse.implementation buf in
let pstr_desc=(List.nth ast 0).pstr_desc in
match pstr_desc with
|Pstr_eval (expression,attributes)->
match expression.pexp_desc with
|Pexp_constant constant->
match constant with
|Pconst_integer (const_int,char_option)->
Printf.printf "%s" const_int;
close_in readhandle
If test.ml have only a integer,for example:1,this prog can read it and return Parsetree.
In the parsetree.mli:
and expression_desc =
| Pexp_ident of Longident.t loc
(* x
M.x
*)
| Pexp_constant of constant
(* 1, 'a', "true", 1.0, 1l, 1L, 1n *)
the Pexp_ident is paralleling to Pexp_constant,if I write parsetreetest2.ml:
let ()=
let filename = "test2.ml" in
Location.input_name := filename ;
let readhandle = open_in filename in
let buf = Lexing.from_channel readhandle in
Location.init buf filename ;
let ast = Parse.implementation buf in
let pstr_desc=(List.nth ast 0).pstr_desc in
match pstr_desc with
|Pstr_eval (expression,attributes)->
match expression.pexp_desc with
|Pexp_ident loc->
match loc with
|Lident l->
Printf.printf "%s" l;
close_in readhandle
in test2.ml I write x,as the parsetree.mli example show me,then compiler with ocamlbuild,which used to compile parsetreetest.ml success,got error:
File "parsetreetest2.ml", line 14, characters 7-13:
Error: Unbound constructor Lident
I don't know why I can't do this,thanks!
ocaml
ocaml
asked Nov 20 '18 at 2:40
wang kaiwang kai
238210
238210
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You don't show a definition for Lident
so the obvious conclusion is that the constructor is undefined, which is exactly what the compiler is telling you. The case that works doesn't use Lident
, so it doesn't have the error.
It sounds like you're working with some pre-existing files. So the thing to do might be to look around and find the definition of Lident
and make sure it is compiled and can be found by the compiler.
If you're copying code from somewhere else, you might look to see whether there are any open
declarations in the other code. Possibly an open
declaration would make Lident
available in your code.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53385438%2fwhats-meaning-of-pexp-ident-use-in-parsetree-mli%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You don't show a definition for Lident
so the obvious conclusion is that the constructor is undefined, which is exactly what the compiler is telling you. The case that works doesn't use Lident
, so it doesn't have the error.
It sounds like you're working with some pre-existing files. So the thing to do might be to look around and find the definition of Lident
and make sure it is compiled and can be found by the compiler.
If you're copying code from somewhere else, you might look to see whether there are any open
declarations in the other code. Possibly an open
declaration would make Lident
available in your code.
add a comment |
You don't show a definition for Lident
so the obvious conclusion is that the constructor is undefined, which is exactly what the compiler is telling you. The case that works doesn't use Lident
, so it doesn't have the error.
It sounds like you're working with some pre-existing files. So the thing to do might be to look around and find the definition of Lident
and make sure it is compiled and can be found by the compiler.
If you're copying code from somewhere else, you might look to see whether there are any open
declarations in the other code. Possibly an open
declaration would make Lident
available in your code.
add a comment |
You don't show a definition for Lident
so the obvious conclusion is that the constructor is undefined, which is exactly what the compiler is telling you. The case that works doesn't use Lident
, so it doesn't have the error.
It sounds like you're working with some pre-existing files. So the thing to do might be to look around and find the definition of Lident
and make sure it is compiled and can be found by the compiler.
If you're copying code from somewhere else, you might look to see whether there are any open
declarations in the other code. Possibly an open
declaration would make Lident
available in your code.
You don't show a definition for Lident
so the obvious conclusion is that the constructor is undefined, which is exactly what the compiler is telling you. The case that works doesn't use Lident
, so it doesn't have the error.
It sounds like you're working with some pre-existing files. So the thing to do might be to look around and find the definition of Lident
and make sure it is compiled and can be found by the compiler.
If you're copying code from somewhere else, you might look to see whether there are any open
declarations in the other code. Possibly an open
declaration would make Lident
available in your code.
answered Nov 20 '18 at 6:02
Jeffrey ScofieldJeffrey Scofield
47.4k24978
47.4k24978
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53385438%2fwhats-meaning-of-pexp-ident-use-in-parsetree-mli%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown