Reputation: 7151
I have a very simple question. I tried to google it, but to no avail.
I installed Mono and F# with Macports in OSX. There are some bugs in F# interactive, but still it's usable if you call it from emacs with F# mode.
Now, the problem is that although F# is there and works, even the simplest of libraries/functions are not available. For instance, the following code doesn't run, with the error that it can't find, neither sum, neither out:
let sumMultiples n =
[1..n]
|> List.filter (fun i -> (i%3 = 0 || i%5 = 0))
|> List.sum
let out = sumMultiples 999
printfn "%d" out
And the error given is:
test.fs(6,12): error FS0039: The value, constructor, namespace or type 'sum' is not defined.
test.fs(10,17): error FS0039: The value or constructor 'out' is not defined.
stopped due to error
What I'm I missing here?
Upvotes: 2
Views: 798
Reputation: 41290
This is the summary of discussion with @jbssm through comments:
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.
whenever
starting fsi.And lets start my answer from here:
#quit;;
. To solve the new problem, you may find the answer of the
following question helpful.I find it a little bit weird because your new F# configuration should work. Have you installed new Mono and F# using or not using MacPorts because it's a known bug of F# on MacPorts? If you're not using MacPorts, my guess is there are some data left from the old Mono installation on MacPorts which conflicts with the new Mono installation. If the first suggestion doesn't work, maybe you should follow the below procedure:
fsi
on the terminal.I have Mono 2.10 with F# running on my Mac (though I don't use Emacs), so I don't think there's any problem installing Mono 2.10 from scratch.
Please give follow-up information, if any of them works for you.
Upvotes: 2
Reputation: 1794
Here are some instructions I recently wrote up for getting F# working under Mono (on Mac) https://github.com/Phrogz/laink/wiki/F%23s-on-Mac
You code works after following those steps:
~/code/fs harold$ cat test.fs
let sumMultiples n =
[1..n]
|> List.filter (fun i -> (i%3 = 0 || i%5 = 0))
|> List.sum
let out = sumMultiples 999
printfn "%d" out
~/code/fs harold$ fsc test.fs
Microsoft (R) F# 2.0 Compiler build 2.0.0.0
Copyright (c) Microsoft Corporation. All Rights Reserved.
~/code/fs harold$ mono test.exe
233168
Upvotes: 2