小编use*_*224的帖子

键入注释以使用F#TypeProvider类型,例如FSharp.Data.JsonProvider <...>.DomainTypes.Url

我正在使用FSharp.Data.JsonProviderTwitter推文.

使用此示例代码 https://github.com/tpetricek/Documents/tree/master/Samples/Twitter.API

我想扩展推文中的网址

let expandUrl (txt:string) (url:Search.DomainTypes<...>.DomainTypes.Url) = 
    txt.Replace( url.Url, url.ExpandedUrl )
Run Code Online (Sandbox Code Playgroud)

这会导致错误:

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.
Run Code Online (Sandbox Code Playgroud)

我的问题是如何TypeProvider在上面的expandUrl函数中定义url 的类型?

类型感染告诉我这个

val urls : FSharp.Data.JsonProvider<...>.DomainTypes.Url []
Run Code Online (Sandbox Code Playgroud)

但是在类型声明中不接受这一点.我假设"<...>"不是F#synatx.

如何使用TypeProvider类型进行类型注释,例如 FSharp.Data.JsonProvider<...>.DomainTypes.Url ?

以下是完整的代码段:

open TwitterAPI // github.com/tpetricek/Documents/tree/master/Samples/Twitter.API 
let twitter = TwitterAPI.TwitterContext( _consumerKey, _consumerSecret, _accessToken, _accessTokenSecret )
let query = "water" …
Run Code Online (Sandbox Code Playgroud)

f# type-parameter type-providers f#-data

6
推荐指数
1
解决办法
1077
查看次数

标签 统计

f# ×1

f#-data ×1

type-parameter ×1

type-providers ×1