f# - 使用匿名记录会产生语法错误:FS0010: Unexpected symbol '|' 在表达
问题描述
我渴望使用 F# 4.6 匿名记录,但编译器似乎并没有“得到它”。如何指定我使用的是 4.6?我尝试了很多谷歌搜索,但没有关于如何实际告诉编译器使用最新版本的文档(?)。
开始一个新的dotnet new console -lang F# -o src/App
,并试图做一个虚拟的例子:
open System
[<EntryPoint>]
let main argv =
let myrec = {| X=3; Y=4 |}
printfn "Hello World from F#! test %A" myrec
0 // return an integer exit code
不起作用,因为:
src/App/Program.fs(5,18): error FS0010: Unexpected symbol '|' in expression [src/App/App.fsproj]
src/App/Program.fs(5,17): error FS0604: Unmatched '{' [src/App/App.fsproj]
我的 App.fsproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
</Project>
解决方案
Turns out it was my .NET Core Runtime that was too far behind. I didn't install the very most recent version because of the unstability warning for MacOS, but I now see that you need the MacOS-unstable version for it to support F# 4.6.
The solution was to just go to https://dotnet.microsoft.com/download/dotnet-core/2.2 and install the most recent version anyway!
推荐阅读
- linux - 如何在 Linux 中已部署的 Matlab exe 中调用已编译的 fortran exe 文件?
- docker - K3S集群证书
- python - 如果表格有不同的选项卡,如何将 html 表格放入 python?
- c++ - 为什么 C++ 中的字符串文字 (char*) 必须是常量?
- node.js - 部署 docker 镜像
- bash - 以root用户身份在脚本bash_aliases中创建别名的问题
- lua - 使用键聚焦时 TextBox 值会发生变化
- python-3.x - 如何从 Python 中的路径获取没有路径的文件名?
- ibm-midrange - AS400 - IBM 批处理作业问题
- python - 在 Python 中对存储在 numpy 数组中的文件夹标签进行编码