Is there a way to look at the contents (i.e. signature) of a structure without opening it?
(I suppose you could just open it then call a lot of PolyML.Compiler.forgetXXX, but that's quite tedious)
Also, is it possible to retrieve the long path of an identifier in scope? Something that will, for example, take the rev in scope and say that it came from List.
Finally, what about searching for an identifier that would come into scope if you opened some structures?
Currently there isn't any straightforward ways of doing any of these. They are all things that would be nice to have and we may get round to doing as part of the general improvements in user-interface. Some of the hooks are there to do these kinds of things but they're not very apparent. We're working on providing support for an IDE and there is a development version of a jEdit plugin in the SVN repository.
Ramana Kumar wrote:
Is there a way to look at the contents (i.e. signature) of a structure without opening it?
It's possible to put the various primitive functions together to this.
local open PolyML open NameSpace in fun showStruct structName = prettyPrint(TextIO.print, 70 (* line width*)) (displayStruct(valOf(#lookupStruct globalNameSpace structName), 1000(*depth*), globalNameSpace)) end;
Also, is it possible to retrieve the long path of an identifier in scope? Something that will, for example, take the rev in scope and say that it came from List.
The compiler does maintain the declaration location of identifiers and in the experimental IDE it's possible to click on an identifier and go to the source file where it was declared.
Finally, what about searching for an identifier that would come into scope if you opened some structures?
Again, it's possible that there are hooks already to do this but they aren't easily accessible. All this could be done with time but it really requires someone to work on improving all this.
Regards, David
It's possible to put the various primitive functions together to this.
local ? ?open PolyML ? ?open NameSpace in ? ?fun showStruct structName = ? ? ? ?prettyPrint(TextIO.print, 70 (* line width*)) ? ? ? ? ? ?(displayStruct(valOf(#lookupStruct globalNameSpace structName), ? ? ? ? ? ? ? 1000(*depth*), globalNameSpace)) end;
That's great, thank you.
The compiler does maintain the declaration location of identifiers and in the experimental IDE it's possible to click on an identifier and go to the source file where it was declared.
I'd love if the locations stored by the compiler were exposed by a procedure too, since I'd rather avoid an IDE.
Again, it's possible that there are hooks already to do this but they aren't easily accessible. ?All this could be done with time but it really requires someone to work on improving all this.
Are there many developers? Who can join them?
Ramana Kumar wrote:
The compiler does maintain the declaration location of identifiers and in the experimental IDE it's possible to click on an identifier and go to the source file where it was declared.
I'd love if the locations stored by the compiler were exposed by a procedure too, since I'd rather avoid an IDE.
Actually I think the information can be got at but in a rather indirect way by using the displayVal/displayStruct etc functions. They produce information about how to pretty print values and also information in the "context" about where the value was declared. This is intended for use by the IDE when printing the information but it could be extracted programmatically.
Poly/ML 5.3 Release
local open PolyML open NameSpace in fun getVal name = displayVal(valOf(#lookupVal globalNameSpace name), 1000(*depth*), globalNameSpace) end;
# # # # # val getVal = fn : string -> PolyML.pretty PolyML.print_depth 100;
val it = () : unit
getVal "rev";
val it = PrettyBlock (3, false, [], [PrettyBlock (0, false, [], [PrettyString "val", PrettyBreak (1, 0), PrettyBlock (0, false, [ContextLocation {file = "./basis/List.sml", endLine = 188, startLine = 188, endPosition = 0, startPosition = 0}], [PrettyString "rev"]), PrettyBreak (1, 0), PrettyString "="]), PrettyBreak (1, 0), PrettyString "fn", PrettyBreak (1, 0), PrettyBlock (3, false, [], [PrettyString ":", PrettyBreak (1, 3), PrettyBlock (0, false, [], [PrettyBlock (0, false, [], [PrettyString "'a", PrettyBreak (1, 0), PrettyBlock (0, false, [ContextLocation {file = "Standard Basis", endLine = 0, startLine = 0, endPosition = 0, startPosition = 0}], [PrettyString "list"])]), PrettyBreak (1, 0), PrettyString "->", PrettyBreak (1, 0), PrettyBlock (0, false, [], [PrettyString "'a", PrettyBreak (1, 0), PrettyBlock (0, false, [ContextLocation {file = "Standard Basis", endLine = 0, startLine = 0, endPosition = 0, startPosition = 0}], [PrettyString "list"])])])])]) : PolyML.pretty
The location information is in the first ContextLocation entry. The others refer to the locations of the "list" type constructors.
Again, it's possible that there are hooks already to do this but they aren't easily accessible. All this could be done with time but it really requires someone to work on improving all this.
Are there many developers? Who can join them?
Well, I'm the only one doing very much developing and it depends on fitting it around other work. Lucas Dixon has been working on the jEdit plugin and various other people have made contributions. It would be good to get more people involved. The best way to get started is to find some feature that you yourself want and try and write it. I'll do what I can to help.
Regards, David
How can I display signatures and structures, by looking up their name in the current environment, in Poly/ML 5.6?
The PolyML.NameSpace structure seems to have been reorganised quite a bit, so the code given previously does not work.
On 29 January 2010 at 04:30, David Matthews <David.Matthews at prolingua.co.uk> wrote:
Ramana Kumar wrote:
The compiler does maintain the declaration location of identifiers and in
the experimental IDE it's possible to click on an identifier and go to the source file where it was declared.
I'd love if the locations stored by the compiler were exposed by a procedure too, since I'd rather avoid an IDE.
Actually I think the information can be got at but in a rather indirect way by using the displayVal/displayStruct etc functions. They produce information about how to pretty print values and also information in the "context" about where the value was declared. This is intended for use by the IDE when printing the information but it could be extracted programmatically.
Poly/ML 5.3 Release
local open PolyML open NameSpace in fun getVal name = displayVal(valOf(#lookupVal globalNameSpace name), 1000(*depth*), globalNameSpace) end;
# # # # # val getVal = fn : string -> PolyML.pretty PolyML.print_depth 100;
val it = () : unit
getVal "rev";
val it = PrettyBlock (3, false, [], [PrettyBlock (0, false, [], [PrettyString "val", PrettyBreak (1, 0), PrettyBlock (0, false, [ContextLocation {file = "./basis/List.sml", endLine = 188, startLine = 188, endPosition = 0, startPosition = 0}], [PrettyString "rev"]), PrettyBreak (1, 0), PrettyString "="]), PrettyBreak (1, 0), PrettyString "fn", PrettyBreak (1, 0), PrettyBlock (3, false, [], [PrettyString ":", PrettyBreak (1, 3), PrettyBlock (0, false, [], [PrettyBlock (0, false, [], [PrettyString "'a", PrettyBreak (1, 0), PrettyBlock (0, false, [ContextLocation {file = "Standard Basis", endLine = 0, startLine = 0, endPosition = 0, startPosition = 0}], [PrettyString "list"])]), PrettyBreak (1, 0), PrettyString "->", PrettyBreak (1, 0), PrettyBlock (0, false, [], [PrettyString "'a", PrettyBreak (1, 0), PrettyBlock (0, false, [ContextLocation {file = "Standard Basis", endLine = 0, startLine = 0, endPosition = 0, startPosition = 0}], [PrettyString "list"])])])])]) : PolyML.pretty
The location information is in the first ContextLocation entry. The others refer to the locations of the "list" type constructors.
Again, it's possible that there are hooks already to do this but they
aren't easily accessible. All this could be done with time but it really requires someone to work on improving all this.
Are there many developers? Who can join them?
Well, I'm the only one doing very much developing and it depends on fitting it around other work. Lucas Dixon has been working on the jEdit plugin and various other people have made contributions. It would be good to get more people involved. The best way to get started is to find some feature that you yourself want and try and write it. I'll do what I can to help.
Regards, David
On 26/01/2016 23:37, Ramana Kumar wrote:
How can I display signatures and structures, by looking up their name in the current environment, in Poly/ML 5.6?
The PolyML.NameSpace structure seems to have been reorganised quite a bit, so the code given previously does not work.
It was getting unwieldy having functions for all the different classes of identifier in one structure so I've split it with separate sub-structures for each class. That allows the same name to be used for similar functions. E.g. each class has a "name" function that returns the name associated with the identifier.
fun getVal name = displayVal(valOf(#lookupVal globalNameSpace name),
1000(*depth*), globalNameSpace) end;
The new way of doing this is fun getVal name = Values.printWithType(valOf(#lookupVal globalNameSpace name), 1000, SOME globalNameSpace)
David