Skip to content

Commit 77880e4

Browse files
shethaaditAdit ShethT-Gro
authored
Enhance F# Interactive Documentation: Add Extended #help Directive Details (#43736)
* Fixed bug 43704. * Formatting. * Update docs/fsharp/tools/fsharp-interactive/index.md Resolving comments. Co-authored-by: Tomas Grosup <[email protected]> * Update docs/fsharp/tools/fsharp-interactive/index.md Resolving comments. Co-authored-by: Tomas Grosup <[email protected]> --------- Co-authored-by: Adit Sheth <[email protected]> Co-authored-by: Tomas Grosup <[email protected]>
1 parent cd75b24 commit 77880e4

File tree

1 file changed

+37
-1
lines changed
  • docs/fsharp/tools/fsharp-interactive

1 file changed

+37
-1
lines changed

docs/fsharp/tools/fsharp-interactive/index.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ The `#r` and `#load` directives seen previously are only available in F# Interac
240240
|`#r "extname:..."`|Reference a package from `extname` extension[^1] (such as `paket`)|
241241
|`#r "assembly-name.dll"`|References an assembly on disk|
242242
|`#load "file-name.fsx"`|Reads a source file, compiles it, and runs it.|
243-
|`#help`|Displays information about available directives.|
243+
|`#help`|Displays information about available directives or documentation for specific functions.|
244244
|`#I`|Specifies an assembly search path in quotation marks.|
245245
|`#quit`|Terminates an F# Interactive session.|
246246
|`#time "on"` or `#time "off"`|By itself, `#time` toggles whether to display performance information. When it is `"on"`, F# Interactive measures real time, CPU time, and garbage collection information for each section of code that is interpreted and executed.|
@@ -249,6 +249,42 @@ The `#r` and `#load` directives seen previously are only available in F# Interac
249249

250250
When you specify files or paths in F# Interactive, a string literal is expected. Therefore, files and paths must be in quotation marks, and the usual escape characters apply. You can use the `@` character to cause F# Interactive to interpret a string that contains a path as a verbatim string. This causes F# Interactive to ignore any escape characters.
251251

252+
### Extended #help directive
253+
254+
The `#help` directive now supports displaying documentation for specific functions. You can pass the name of the function directly (without quotes) to retrieve details.
255+
256+
```fsharp
257+
#help List.map;;
258+
```
259+
260+
The output is as follows:
261+
262+
```console
263+
Description:
264+
Builds a new collection whose elements are the results of applying the given function
265+
to each of the elements of the collection.
266+
267+
Parameters:
268+
- mapping: The function to transform elements from the input list.
269+
- list: The input list.
270+
271+
Returns:
272+
The list of transformed elements.
273+
274+
Examples:
275+
let inputs = [ "a"; "bbb"; "cc" ]
276+
277+
inputs |> List.map (fun x -> x.Length)
278+
// Evaluates to [ 1; 3; 2 ]
279+
280+
Full name: Microsoft.FSharp.Collections.ListModule.map
281+
Assembly: FSharp.Core.dll
282+
```
283+
284+
This enhancement makes it easier to explore and understand F# libraries interactively.
285+
286+
For more details, refer to the [official devblog](https://devblogs.microsoft.com/dotnet/enhancing-help-in-fsi/).
287+
252288
## Interactive and compiled preprocessor directives
253289

254290
When you compile code in F# Interactive, whether you are running interactively or running a script, the symbol **INTERACTIVE** is defined. When you compile code in the compiler, the symbol **COMPILED** is defined. Thus, if code needs to be different in compiled and interactive modes, you can use these preprocessor directives for conditional compilation to determine which to use. For example:

0 commit comments

Comments
 (0)