読者です 読者をやめる 読者になる 読者になる

IT練習ノート

IT関連で調べたこと(実際は嵌ったこと)を書いています。

MacでのF#の環境設定

fsharp

f:id:naotoogawa:20161120145918p:plain

  • Monoのインストール

f:id:naotoogawa:20161120135049p:plain

  • 指示に従ってインストールする

f:id:naotoogawa:20161120135109p:plain

f:id:naotoogawa:20161120135110p:plain

f:id:naotoogawa:20161120135111p:plain

f:id:naotoogawa:20161120135112p:plain

f:id:naotoogawa:20161120135115p:plain

f:id:naotoogawa:20161120135116p:plain

f:id:naotoogawa:20161120135117p:plain

  • インストールされる中身
This README is for Mono.framework 4.6.2_7.

This is the Mono Runtime and Development Platform (http://www.mono-project.com/).

This package installs Mono and all of its dependencies inside of /Library/Frameworks/Mono.framework.  This behavior is likely to change with a future release so that dependancies will get their own frameworks.

The following components are included inside Mono.framework:
autoconf v. 2.69
automake v. 1.13
gettext v. 0.18.2
pkg-config v. 0.27
libpng v. 1.4.12
libjpeg v. 8
tiff v. 4.0.3
giflib v. 4.1.6
libxml2 v. 2.9.1
freetype v. 2.5.0.1
fontconfig v. 2.10.2
pixman v. 0.30.0
cairo v. 1.12.14
libffi v. 3.0.13
glib v. 2.36.4
pango v. 1.35.0
atk v. 2.8.0
intltool v. 0.50.2
gdk-pixbuf v. 2.28.2
gtk+ v.2.24 (master-2.24.22-3-g280fc40)
libglade v. 2.6.4
sqlite-autoconf v. 3090200
expat v. 2.0.1
ige-mac-integration v. 0.9.4
libcroco v. 0.6.8
librsvg v. 2.37.0
hicolor-icon-theme v. 0.12
gtk-engines v. 2.20.2
murrine v. 0.98.2
xamarin-gtk-theme v.0.98.2 (master-cc3fb66)
gtk-quartz-engine v.0.1 (master-v0.1-29-g9555a08)
llvm v.3.0 (master-8b1520c)
mono v.4.6.2 (mono-4.6.0-branch-mono-4.6.2.6-1-g08fd525)
msbuild v.14.1 (xplat-p1-dcc94a7)
PortableReferenceAssemblies v. 2014-04-14
libgdiplus v. 2.11
xsp v. 4.4
gtk-sharp v. 2.12.21
iron-languages v. 2.11
fsharp v. 4.0.1.9
mono-basic v. 4.6
nuget v.2.12.0 (master-2.7.1-605-g9e2d2c1)
mono-extensions (mono-4.6.0-branch-4f354fd)
ms-test-suite v.0.1 (master-eb7cd70)

Other packages used to build Mono.framework:
bockbuild (rev. d9a428be30fff40c638e99ee7751588565eb98c5)
autoconf v. 2.69
automake v. 1.13
ccache v.3.1.9 (master-v3.1.9-321-g55f1fc6)
libtool v. 2.4.2
xz v. 5.0.4
tar v. 1.26
gtk-osx-docbook v. 1.0
gtk-doc v. 1.18
If you want to build native Mac applications with Mono, you can use the MonoMac bindings, an add-on to this product available from http://www.mono-project.com/MonoMac




A simple uninstallMono.sh script is included in the disk image.  This is shell script that must be run as root, and it will remove the Mono.framework and the links in /usr/bin.

This package was created by the Mono team.  Major contributors to this team include (in alphabetical order): 

Wade Berrier
Adhamh Findlay
Miguel de Icaza
Urs Muff
Geoff Norton
Andy Satori

Questions or problems related directly to the Mono.framework should be addressed to mono-osx@lists.xamarin.com.

Questions about Mono should be directed to an appropriate resource that can be found on http://www.mono-project.com/about. 
export PATH=$PATH:/Library/Frameworks/Mono.framework/Versions/Current/bin
  • Monoインストールの確認
$ mcs -help
Mono C# compiler, Copyright 2001-2011 Novell, Inc., Copyright 2011-2012 Xamarin, Inc
mcs [options] source-files
   --about              About the Mono C# compiler
   -addmodule:M1[,Mn]   Adds the module to the generated assembly
   -checked[+|-]        Sets default aritmetic overflow context
   -clscheck[+|-]       Disables CLS Compliance verifications
   -codepage:ID         Sets code page to the one in ID (number, utf8, reset)
   -define:S1[;S2]      Defines one or more conditional symbols (short: -d)
   -debug[+|-], -g      Generate debugging information
   -delaysign[+|-]      Only insert the public key into the assembly (no signing)
   -doc:FILE            Process documentation comments to XML file
   -fullpaths           Any issued error or warning uses absolute file path
   -help                Lists all compiler options (short: -?)
   -keycontainer:NAME   The key pair container used to sign the output assembly
   -keyfile:FILE        The key file used to strongname the ouput assembly
   -langversion:TEXT    Specifies language version: ISO-1, ISO-2, 3, 4, 5, Default or Experimental
   -lib:PATH1[,PATHn]   Specifies the location of referenced assemblies
   -main:CLASS          Specifies the class with the Main method (short: -m)
   -noconfig            Disables implicitly referenced assemblies
   -nostdlib[+|-]       Does not reference mscorlib.dll library
   -nowarn:W1[,Wn]      Suppress one or more compiler warnings
   -optimize[+|-]       Enables advanced compiler optimizations (short: -o)
   -out:FILE            Specifies output assembly name
   -pkg:P1[,Pn]         References packages P1..Pn
   -platform:ARCH       Specifies the target platform of the output assembly
                        ARCH can be one of: anycpu, anycpu32bitpreferred, arm,
                        x86, x64 or itanium. The default is anycpu.
   -recurse:SPEC        Recursively compiles files according to SPEC pattern
   -reference:A1[,An]   Imports metadata from the specified assembly (short: -r)
   -reference:ALIAS=A   Imports metadata using specified extern alias (short: -r)
   -sdk:VERSION         Specifies SDK version of referenced assemblies
                        VERSION can be one of: 2, 4, 4.5 (default) or a custom value
   -target:KIND         Specifies the format of the output assembly (short: -t)
                        KIND can be one of: exe, winexe, library, module
   -unsafe[+|-]         Allows to compile code which uses unsafe keyword
   -warnaserror[+|-]    Treats all warnings as errors
   -warnaserror[+|-]:W1[,Wn] Treats one or more compiler warnings as errors
   -warn:0-4            Sets warning level, the default is 4 (short -w:)
   -helpinternal        Shows internal and advanced compiler options

Resources:
   -linkresource:FILE[,ID] Links FILE as a resource (short: -linkres)
   -resource:FILE[,ID]     Embed FILE as a resource (short: -res)
   -win32res:FILE          Specifies Win32 resource file (.res)
   -win32icon:FILE         Use this icon for the output
   @file                   Read response file for more options

Options can be of the form -option or /option
  • Visual Studio Code に拡張機能をインストールする。
    • Code Runner
    • Ionide-fsharp fsharpのintellsence
    • Ionide-FAKE fsharpのmake機能
    • Ionide-Paket パッケージ管理?
    • Mono Debug デバック環境

f:id:naotoogawa:20161120135720p:plain

  • Macで環境設定をしているので、コード片を実行する設定をする。

f:id:naotoogawa:20161120140140p:plain

  • 規定の設定にRun Code configurationcode-runner.executorMapfsharpの項目にfsiが指定されている。別ファイルのsetting.jsonfsharpiを記述して、規定の設定を上書きする。
{
        "code-runner.executorMap": {
                    "fsharp": "fsharpi"
        }
}
  • 拡張子fsxのファイルを作成し、コードを書く。
let helloWorld =
    "Hello world from fsharpi"

printfn "%s" helloWorld

f:id:naotoogawa:20161120144906p:plain

f:id:naotoogawa:20161120144907p:plain