In F# interactive, how can I see a list of variables/functions defined in this session? Like a function whos()
in python or ls()
in R? Thanks.
相关问题
- F#: Storing and mapping a list of functions
- Multiplying a list of tuples by a tuple in F#
- Multiplying a string in F#
- F# odd pattern matching issues
- Why doesn't bindingRedirect affect FSharp.Core
相关文章
- FSharp.Data.JsonProvider - Getting json from types
- Signing an F# Assembly (Strong name component)
- Learning F#: What books using other programming la
- fsc.exe is very slow because it tries to access cr
- Extension methods for specific generic types
- F# Object Initialization with a Constructor
- F# Lazy Evaluation vs Non-Lazy
- When to use interfaces, and when to use higher ord
You can probably implement this using .NET Reflection - local variables and functions are defined as static properties/methods of types in a single dynamic assembly. You can get that assembly by calling
GetExecutingAssembly
(in FSI itself) and then browse the types to find all suitable properties.The following is a reasonably working function for getting local variables:
Here is an example:
The function returns "lazy" value back (because this was the simplest way to write it without reading values of all variables in advance which would be slow), so you need to use the
Value
property. Also note that you getobject
back - because there is no way the F# type system could know the type - you'll have to use it dynamically. You can get all names just by iterating overvars
...I'm developing FsEye, which uses a modified version of @Tomas' technique (filters out unit and function valued vars and only takes the latest
it
var) to grab all FSI session variables upon each submission and displays them visually in a tree so that you can drill down into their object graphs.You can see my modified version here.
Unfortunately there is no way to do this in FSI at this stage.