Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

F# Command Line Interactive Repl

Tags:

linux

f#

I'm on linux and I'd like to use an interactive command line repl for F#.

For example, like the node repl.

What options are there?

like image 837
Mateja Petrovic Avatar asked Jan 28 '23 10:01

Mateja Petrovic


2 Answers

Rather than typing directly into a REPL, I recommend creating an F# script file (.fsx) in an editor with F# support, e.g. Visual Studio Code. Then you can type script code with the usual benefits type-checking and auto-completions, and just select sections of code and send them to FSI (F# Interactive), usually by pressing Alt-Enter.

like image 126
TheQuickBrownFox Avatar answered Jan 29 '23 23:01

TheQuickBrownFox


TheQuickBrownFox has a good suggestion, but sometimes I find it's easier to type a quick bit of test code into an actual REPL rather than editing an .fsx file in VS Code. The F# REPL is available with the fsharpi command. It's part of the fsharp package (at least on Debian-based systems) so you should already have it installed.

like image 26
rmunn Avatar answered Jan 30 '23 00:01

rmunn