【问题标题】:Search in web with F#使用 F# 在 Web 中搜索
【发布时间】:2018-05-12 22:30:21
【问题描述】:

嗨,我想搜索页面上存在的所有功能语言,每个编程语言都列在一个表格中,我使用的页面是:https://en.wikipedia.org/wiki/Comparison_of_multi-paradigm_programming_languages#Paradigm_summaries

我将在两个元组中得到结果,我用来完成这个的代码是:

#r "/usr/lib/cli/fsharp/FSharp.Data.2.4.2/lib/net45/FSharp.Data.dll"
open FSharp.Data
type Multiparadigm = HtmlProvider<"https://en.wikipedia.org/wiki/Comparison_of_multi-paradigm_programming_languages#Paradigm_summaries">
let multi =
    [ for x in Multiparadigm.GetSample().Tables.``Lenguage overview``.Rows ->
        x.Type, x.``Functional`` ]

我将它保存在一个 .fsx 文件中,当我在 ubuntu 中使用 Fsharpc 时,我得到的错误是:

/Documents/Fsharp/testF#/getDataFPage.fsx(5,43): error FS0039: The field, constructor or member 'Languaje overview' is not defined

/Documents/Fsharp/testF#/getDataFPage.fsx(6,9): error FS0072: Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.

/Documents/Fsharp/testF#/getDataFPage.fsx(6,17): error FS0072: Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.

我想知道我做错了什么,因为在我得到的交互式工具中:

Referenced '/usr/lib/cli/fsharp/FSharp.Data.2.4.2/lib/net45/FSharp.Data.dll' (file may be locked by F# Interactive process)

【问题讨论】:

  • 我正在使用 nuget 安装 FSharp.Data 并且已经在寻找它以确保 FSharp.Data.dll 位于正确的路径中

标签: types f# functional-programming


【解决方案1】:

你有一个错字,它是 Language 不是 Lenguage 也不是 Languaje

还要注意Type 属性不存在。

因此,如果您对代码进行这两个小的更改,它应该可以工作:

#r "/usr/lib/cli/fsharp/FSharp.Data.2.4.2/lib/net45/FSharp.Data.dll"
open FSharp.Data
type Multiparadigm = HtmlProvider<"https://en.wikipedia.org/wiki/Comparison_of_multi-paradigm_programming_languages#Paradigm_summaries">
let multi =
    [ for x in Multiparadigm.GetSample().Tables.``Language overview``.Rows ->
        x.Language,  x.``Func­tion­al`` ]

它给了你这样的东西:

type Multiparadigm = HtmlProvider<...>
val multi : (string * string) list =
  [("Ada[3][4][5][6][7]", "No"); ("ALF", "Yes");
   ("AmigaE[citation needed]", "No"); ("APL", "Yes");
   ("BETA[citation needed]", "Yes"); ("C++", "Yes"); ("C#", "Yes[a 5]");
...

【讨论】:

    猜你喜欢
    • 2015-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-21
    • 2018-08-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多