How to use MathNet.Numerics.FSharp in FSI

So I wanted to explore
MathNet.Numerics.FSharp

I open a repl
dotnet fsi

Now I have no clue how to open MathNet.Numerics.FSharp in the repl

#r “MathNet.Numerics.FSharp” doesnt work
and dotnet add package MathNet.Numerics.FSharp --version 4.12.0 needs a project

It doesnt seem possible to install a package outside of a project system wide, like for Python or Perl

For the record I am running

Microsoft (R) F# Interactive version 10.8.0.0 for F# 4.7

Also while it seems that

Install-Package

does install packages system wide and per user (with flag -Scope CurrentUser),
it also seem that dotnet fsi doest try to check those paths for packages
Or am I missing something

Any advice

1 Like

Also I was pointed out to this link on slack

And the commend are closed on this article, so here are my comments

#r “nuget: Newtonsoft.Json”
open Newtonsoft.Json

Is the wrong solution for scripting
For scripting , packages should be install in a central directory, system wide or per user
this should be achieve by using

Install-Package

Dependency resolution should be done on the command line

dotnet fsi script.fsx

Should read the open Package line, analyze dependencies and raise warning about missing dependencies
the user should warning about which packages are not install, the the warning message should guide him how to resolve it

Additional command line option can be use to automatically install missing dependencies
For example

dotnet fsi script.fsx --Install-Dependencies -Scope CurrentUser

Additional command line option can added for example to test dependcies

dotnet fsi script.fsx --Check-Dependencies
And raise the warnings, without attempting to run the script

the line

#r “nuget: Newtonsoft.Json”

Is redundant specially when the following line is

open Newtonsoft.Json

1 Like

I think all of your comments are spot on! Did you get it working?

Well I made some progress and understood few things better, but no
I never got

open MathNet.Numerics.FSharp

to work in FSI

What I learned more about dotnet was,
Install-Package in powershell is not the same Install-Package command that run inside visual studio and mentioned on the nuget site
The install-package command mentioned on the nuget site, is a command that runs inside visual studio

dotnet doesnt have (I think) a package manager that works like cpan or pip , nuget a project oriented tool, cpan or pip are system oriented tool

Inside fsi, opened with langversion preview

dotnet fsi --langversion:preview

#r "nuget: MathNet.Numerics.FSharp";;
open MathNet.Numerics.FSharp;;

Should have worked, but it doesnt , it does work for other libraries thought like Newtonsoft.Json
In the slack chatroom they explained to me that

#r "nuget: ...";;

In needed for some reason, and not redundant, but I forgot why

Anyway, the conclusion is, dotnet doesnt have a tool like cpan, and doest work like many other scripting languages that does have a cpan like tool

Its just easier to create a stub project to explore libraries and packages, dotnet is not for scripting
I dont think MS have any plans to make a real scripting language , and I still think that

#r "nuget: ...";;

Without a CPAN like tool, it is not enough … for scripting , I have not clue what is installed on my system and what isnt

Why does

#r "nuget: Newtonsoft.Json";;
open Newtonsoft.Json;;

work but

#r "nuget: MathNet.Numerics.FSharp";;
open MathNet.Numerics.FSharp;;

doesnt , I have no clue

so MathNet.Numerics.FSharp namespace doesnt exist, only MathNet.Numerics
so it make sense that open MathNet.Numerics.FSharp doesnt work

but note

open MathNet.Numerics;;

must directly follow

#r "nuget: MathNet.Numerics.FSharp";;

If i do

#r "nuget: MathNet.Numerics.FSharp";;
open MathNet.Numerics.FSharp;;

then

open MathNet.Numerics;;

it doesnt work

but if I do

#r "nuget: MathNet.Numerics.FSharp";;
open MathNet.Numerics;;

it works

I asked on slack, this odd behavior of open having to directly follow #r "nuget: .." was corrected in more recent versions

so here we go, it should work

1 Like

Did you have a fix on this issue? I am facing the same issue last time but no response from anyone and couldn’t find the topic troubleshooting in google.

MyMileStoneCard Login