You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/fsharp/tools/fsharp-interactive/index.md
+37-1Lines changed: 37 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -240,7 +240,7 @@ The `#r` and `#load` directives seen previously are only available in F# Interac
240
240
|`#r "extname:..."`|Reference a package from `extname` extension[^1] (such as `paket`)|
241
241
|`#r "assembly-name.dll"`|References an assembly on disk|
242
242
|`#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.|
244
244
|`#I`|Specifies an assembly search path in quotation marks.|
245
245
|`#quit`|Terminates an F# Interactive session.|
246
246
|`#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
249
249
250
250
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.
251
251
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
+
252
288
## Interactive and compiled preprocessor directives
253
289
254
290
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