No apology required it’s a very good question. Unfortunately these facilities are not yet implemented in the F# shell. You can get a list of definition using reflection on the shells internals ... but it’s not really an easier thing to do, and it’s a bit brittle as the internals of the shell may change over time, breaking the any script you may have wrote to do this. However if you’re feeling adventurous this snippet will get you some of the way there:

1
2
3
4
5
6
7
open System;;
let t = Type.GetType("Microsoft.FSharp.Compiler.Interactive.Shell");;
let shellType = Type.GetType("Microsoft.FSharp.Compiler.Interactive.Shell, fsi, Version=1.9.2.9, Culture=neutral, PublicKeyToken=null");;
let stateProp =  shellType.GetProperty("istateRef");;
let statePropGet = stateProp.GetGetMethod();;
let state = statePropGet.Invoke(null, [||]);;
state;;

The variable “state” will contain all previous definitions, somewhere. I think this is in the "tcState" property, but I’m not 100% sure.

However, I know that F# team are planning to look at ways to make the shell more user friendly. Probably including the listing previously defined types and values as you suggest, but I don’t know when they are planning to do this or exactly what features will be included.

By on 8/28/2007 5:13 AM ()

Thanks, Robert! It looks pretty complicated so I think I'll probably just wait for the feature to show up.

By on 9/30/2007 10:22 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper