F# interactive shell (fsi) tutorial? - f#

I'm learning F# with fsi on Mac OS X/mono, but it's hard to know what command to quit and out to shell.
quit, or ^D doesn't work, ^C also doesn't work. What's the command to to stop the fsi?
In general, where can I find some tutorial/user's guide about fsi?

Use #help;; for help, #quit;; to quit.

When I start F# in OS X/mono I get the following
~> fsi
Microsoft (R) F# 2.0 Interactive build 2.0.0.0
Copyright (c) Microsoft Corporation. All Rights Reserved.
For help type #help;;
By typing #help I get:
> #help;;
F# Interactive directives:
#r "file.dll";; Reference (dynamically load) the given DLL
#I "path";; Add the given search path for referenced DLLs
#load "file.fs" ...;; Load the given file(s) as if compiled and referenced
#time ["on"|"off""];; Toggle timing on/off
#help;; Display help
#quit;; Exit
F# Interactive command line options:
See 'fsi --help' for options
>
These should provide your answers.

Related

F# - FSI- Load source file "Process is terminated due to StackOverflowException"

I have updated Visual Studio Community 2019 to Version 16.11.4 and when I try to load a source file (i.e.: Library1.fs) into the FSI environment (trough Alt+Enter or writing the #load command inside the FSI environment inside VISUAL STUDIO), I get the Stack Overflow Exception error:
Microsoft (R) F# Interactive versione 11.4.2.0 per F# 5.0
Copyright (C) Microsoft Corporation. Tutti i diritti sono riservati.
Per informazioni, digitare #help;;
#load "C:\Users\GianLuca\Source\Repos\x\x\Library1.fs";;
Process is terminated due to StackOverflowException.
Session termination detected.
This happen everytime I try to “Load” any source file, event an empty source file!!
NOTE: I’m using F-Sharp Library (.NET Framework 4.72), but the same occurs with CLASS LIBRARY (.NTE STANDARd or .NET CORE)
NOTE: if I lunch “dotnet fsi” from the command prompt (cmd) - outside form Visual Studio - and I try to “Load” the same files, it works fine (no Stack Overflow Exception!).
NOTE: I have launched the REPAIR action from the VISUAL STUDIO INSTALLER, but the problem persists.
How I can resolve it? I’m confused.
It seems a problem of F# INTERACTIVE inside Visual Studio Community 2019 Version 16.11.4
Many thanks in advance!
(See also: https://developercommunity.visualstudio.com/t/F---FSI--Load-source-file-Process-is-t/1550593)

LuaRocks Installation in Win 10 does nothing

I just started learning Lua few days ago.
My system:
Windows 10
Lua 5.2.4 Copyright (C) 1994-2015 Lua.org, PUC-Rio
I downloaded and unzipped LuaRocks-3.5.0-Windows-64.zip. After clicking the exe and allowing the running permission, I could see a flickering command prompt. It just disappeared.
What shall I do next to install it?
Thanks.
The next or actually first step is obviously to read the manual.
Let me quote https://github.com/luarocks/luarocks/wiki/Installation-instructions-for-Windows
unpack it and you'll have a luarocks.exe ready to use.
You do not have to "install" luarocks. The zip file contains two executables. Put them in a folder and ideally add that folder to your PATH system variable.
Once you've downloaded and extracted the archive read
https://github.com/luarocks/luarocks/wiki/Using-LuaRocks
That's command line tools. You run them from the command line. Double-clicking them won't do much as you don't provide any options/arguments like that.

How do I get lua to run on a mac OS X 10.11.6

I downloaded the lua files and "installed" them using the 'make' command.
However, evidently, one just does not type the command lua in the terminal (unlike say python) to get lua to run.
If, in terminal, I go to the lua src directory, and enter ./lua, it will come up.
I.e. Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
I also made an alias
lua="home directory path /lua-5.3.3/src/lua" it will come up; and if I enter say
lua hello.lua; the lua hello text file will run as expected.
This sure seems to be a somewhat convoluted way to call lua up.
Am I doing this correctly, or did I miss something?
Thank you
I believe you want to run make install or sudo make install in the lua directory

FSI.exe does not work under Ubuntu 10.10

Update:
Tried November CTP release. Same error message.
Forgot to mention that this server has the Ubuntu server edition installed. I don't have this issue on my Ubuntu desktop that runs Desktop 10.10.
So I suspected that it could be some command line related libraries missing. After I installed libreadline-dev and libreadline5, the error message disappeared. However, the issue that fsi stuck is still there.
Update2:
Tried the new Mono 2.8.1. Same FSI stuck issue.
Update3:
As this issue is very reproducible, I reported it as a bug in fsi.exe to Microsoft. Let's see how it goes.
Update4:
Got quick response from Don Syme. The solution he suggested resolved this issue. I created the answer myself.
Hi,
I installed F# 2.0 in a server running Ubuntu 10.10 and Mono 2.8. fsc.exe runs perfect, I have no problem in compiling fs files. However, when I run fsi.exe as follows:
mono /usr/local/FSharp/bin/fsi.exe
I got the FSI prompt, but an error message keep repeating
"Failed to install ctrl-c handler - Ctrl-C handling will not be available. Error was:
Exception has been thrown by the target of an invocation"
Am I missing anything here?
The Mono 2.8 was compiled and installed from source.
Feel really awkward to answer my own question. Anyway, I'll answer it so other people can benefit from.
First of all, install libreadline-dev and libreadline5 so you can get rid of the following error message
Failed to install ctrl-c handler - Ctrl-C handling will not be available. Error was: Exception has been thrown by the target of an invocation
If you encounter fsi.exe stuck issue, try
fsi --gui-
It works perfectly in my case.
Here is my understanding of why such an issue happened. If you look into the code, you will find out fsi.exe actually references System.Windows.Forms, which further links to the Window system. In my case, I ran fsi in a server without X system installed. Consequently, fsi stuck there trying to talk to the nonexistent X. That explains why I don't have the issue in my desktop.
F# has never worked for me under Linux. Today with Mono 2.8 and the November 2010 drop of F# (which confusingly has the exact same version number as the previous release?!) I get:
$ sudo ./install-mono.sh
In order to add FSharp.Core.dll to the Mono GAC the DLL needs to be
re-signed with the mono.snk key. The mono.snk key is available from
the 'Mono Sources'.
http://www.mono-project.com/
http://github.com/mono/mono/raw/master/mcs/class/mono.snk
For example, run:
wget -O mono.snk http://github.com/mono/mono/raw/master/mcs/class/mono.snk
Then re-run this script.
An alternative to installing the DLLs in the Mono GAC is to add the
FSharp bin directory to the MONO_PATH variable. For more information
on 'How Mono Finds Assemblies' see http://www.mono-project.com/Gacutil
If I run the wget command that it suggests then it dies:
$ wget -O mono.snk http://github.com/mono/mono/raw/master/mcs/class/mono.snk
--2010-11-23 17:02:43-- http://github.com/mono/mono/raw/master/mcs/class/mono.snk
Resolving github.com... 207.97.227.239
Connecting to github.com|207.97.227.239|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://github.com/mono/mono/raw/master/mcs/class/mono.snk [following]
--2010-11-23 17:02:44-- https://github.com/mono/mono/raw/master/mcs/class/mono.snk
Connecting to github.com|207.97.227.239|:443... connected.
ERROR: certificate common name `*.github.com' doesn't match requested host name `github.com'.
To connect to github.com insecurely, use `--no-check-certificate'.
Unable to establish SSL connection.
Now if I rerun the F# installer I get a different error:
$ sudo ./install-mono.sh
-- Resigning FSharp.Core.dll with mono.snk
ERROR: Invalid number of parameters.
Usage: sn [-q | -quiet] options [parameters]
-q | -quiet Quiet mode (minimal display)
Help options
-? | -h Show this help screen about the tool
-? | -h config Configuration options
-? | -h csp Crypto Service Provider (CSP) related options
-? | -h convert Format convertion options
-? | -h sn StrongName signing options
-- Installing FSharp DLLS into the GAC
Failure adding assembly bin/FSharp.Core.dll to the cache: Strong name cannot be verified for delay-signed assembly
If I copy the mono.snk file from the Mono 2.8 directory into the F# directory by hand then the installer seems to work:
$ sudo ./install-mono.sh
-- Resigning FSharp.Core.dll with mono.snk
Assembly bin/FSharp.Core.dll signed.
-- Installing FSharp DLLS into the GAC
Installed bin/FSharp.Core.dll into the gac (/usr/local/lib/mono/gac)
But F# itself still fails to work in exactly the same way that it did before (appearing to hang whenever input is entered):
$ mono bin/fsi.exe
Microsoft (R) F# 2.0 Interactive build 2.0.0.0
Copyright (c) Microsoft Corporation. All Rights Reserved.
For help type #help;;
> 1+2*3;;
I have to use CTRL+Z to regain control and then kill %1 to kill the rogue process.

SharpDevelop: "Could not find fsi.exe" even when f# is installed

I installed a copy of f# on my machine (on a secondary drive), and when i try to start the F# interactive prompt, it says it could not find fsi.exe. Do i need to copy some files somewhere or something?
You could try to look here:
"%ProgramFiles(x86)%\Microsoft SDKs\F#\<fsharp_version>\Framework\<dotnet_version>\Fsi.exe"
With the VS 15.8 update it appears to have been moved. I found it in:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\FSharp\fsi.exe
Could you be more specific with your repro steps? I assume you are using the latest, May 2009 CTP? Also, when you say 'start the F# Interactive prompt' are you talking about launching it from the start menu?
On most machines it will be exactly:
"C:\Program Files (x86)\FSharp-1.9.7.4\bin\fsi.exe"
If you did something non-standard it could just be a bug in the installer. E.g., did you override the Program Files folder for your F# installation by passing in a command line parameter to msiexec?
Do a quick search for fsi.exe on your machine (the console F# interactive window) and point your shortcut there.

Resources