[英]Mono, F# libraries not working under Mac OSX
I have a very simple question. 我有一个非常简单的问题。 I tried to google it, but to no avail.
我试图用谷歌搜索,但无济于事。
I installed Mono and F# with Macports in OSX. 我在OSX中用Macports安装了Mono和F#。 There are some bugs in F# interactive, but still it's usable if you call it from emacs with F# mode.
F#交互中有一些错误,但是如果您以F#模式从emacs调用它,仍然可以使用。
Now, the problem is that although F# is there and works, even the simplest of libraries/functions are not available. 现在的问题是,尽管F#可用并且可以使用,但即使是最简单的库/功能也无法使用。 For instance, the following code doesn't run, with the error that it can't find, neither sum , neither out :
例如,以下代码无法运行,并且找不到错误, sum , 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? 我在这里想念什么?
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 这是我最近为使F#在Mono(在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
This is the summary of discussion with @jbssm through comments: 这是通过评论与@jbssm进行讨论的摘要:
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.
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.
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;;
#quit;;
,我认为您总是可以使用#quit;;
. I find it a little bit weird because your new F# configuration should work. 我觉得有些奇怪,因为您的新F#配置应该可以使用。 Have you installed new Mono and F# using or not using MacPorts because it's a known bug of F# on MacPorts?
您是否使用或不使用MacPorts安装了新的Mono和F#,因为它是MacPorts上F#的已知错误 ? 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.
如果您不使用MacPorts,我的猜测是MacPorts上的旧Mono安装剩余了一些数据,这些数据与新的Mono安装冲突。 If the first suggestion doesn't work, maybe you should follow the below procedure:
如果第一个建议不起作用,则可能应遵循以下步骤:
fsi
on the terminal. fsi
尝试测试脚本。 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. 我的Mac上运行的是F#的Mono 2.10(尽管我不使用Emacs),所以我认为从头开始安装Mono 2.10没有任何问题。
Please give follow-up information, if any of them works for you. 如果有任何适合您的信息,请提供后续信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.