How to install and use F# Powerpack in Mono?

耗尽温柔 提交于 2019-12-06 01:07:35

问题


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:


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!