How to install and use F# Powerpack in Mono?

2019-04-08 03:30发布

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.

  1. Download the powerpack zip file from here.

  2. Unzip the file to directory ~/bin.

  3. 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)
  4. For the dlls in the ~/bin/FSharpPowerPack-1.9.9.9/bin/gac, use the command sudo 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

  1. 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

  2. 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条回答
冷血范
2楼-- · 2019-04-08 03:44

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()
查看更多
登录 后发表回答