问题
I need to install use F# powerpack. I use mono version 2.10.2 on Mac.
mono --version
Mono JIT compiler version 2.10.2 (tarball Mon Apr 18 09:14:01 MDT 2011)
Copyright (C) 2002-2011 Novell, Inc and Contributors. www.mono-project.com
TLS: normal
SIGSEGV: normal
Notification: kqueue
Architecture: x86
Disabled: none
Misc: debugger softdebug
LLVM: yes(2.9svn-mono)
GC: Included Boehm (with typed GC)
Installation.
Download the powerpack zip file from here.
Unzip the file to directory
~/bin
.- Add the
~/bin/FSharpPowerPack-1.9.9.9/bin
to the PATH. I also add it to the MONO_PATH just in case. (I'm not sure if this is necessary or not) - For the dlls in the
~/bin/FSharpPowerPack-1.9.9.9/bin/gac
, use the commandsudo gacutil -i <ALL_THE_FILES_IN_DLL>.dll
Using the powerpack
I tested with the sample code in this page. I name it linq.fs
open Microsoft.FSharp.Linq
let adderExpr = <@ fun i -> i + 1 @>.ToLinqExpression()
let adder = <@ fun i -> i + 1 @>.Compile()
Questions
I got errors with
fsc linq.fs /r:FSharp.PowerPack.Linq.dll
. What might be wrong?/Users/smcho/Desktop/fs/powerpack/linq.fs(1,38): error FS0039: The field, constructor or member 'ToLinqExpression' is not defined
/Users/smcho/Desktop/fs/powerpack/linq.fs(2,34): error FS0039: The field, constructor or member 'Compile' is not defined
Do I need to install all the dll with
gacutil -i
? Or, just appending the dll path to the PATH/MONO_PATH environment variable is just good enough?
回答1:
Your installation procedure seems to be correct (just unzip and install using gacutil -i
). I think there is just a minor issue with the sample - the ToLinqExpression
extension method is available in a module that needs to be explicitly opened, so your file should be:
EDIT The right module name is actually Microsoft.FSharp.Linq.QuotationEvaluation
:
open Microsoft.FSharp.Linq.QuotationEvaluation
let adderExpr = <@ fun i -> i + 1 @>.ToLinqExpression()
let adder = <@ fun i -> i + 1 @>.Compile()
来源:https://stackoverflow.com/questions/6206406/how-to-install-and-use-f-powerpack-in-mono