我正在尝试从 Suave.io 为一个简单的 F# 项目编译获取此示例:http: //suave.io/
open Suave.Http.Applicatives
open Suave.Http.Successful
open Suave.Web
open Suave.Types
open Suave.Model
let greetings q =
defaultArg (q ^^ "name") "World" |> sprintf "Hello %s"
let sample : WebPart =
path "/hello" >>= choose [
GET >>= request(fun r -> OK <| greetings (query r))
POST >>= request(fun r -> OK <| greetings (form r))
NOT_FOUND "Found no handlers" ]
不幸的是,我在 (query r) 部分遇到了编译器错误:
error FS0001: Expecting a type supporting the operator '^^' but given a function type. You may be missing an argument to a function.
我试图将编译器错误缩小到几行简单的行,现在有了:
let greetings q =
defaultArg (q ^^ "name") "World" |> sprintf "Hello %s"
let q (rqst : string) = query rqst
let t = greetings q
现在在问候 q 行上得到同样的编译器错误。我上面示例中的类型是:
query:
string -> (string -> Choice<'T,string>) -> HttpRequest -> Choice<'T,string>
greetings:
(string -> (string -> Choice<obj,string>) -> HttpRequest -> Choice<obj, string>) -> string
q:
string -> ((string -> Choice<'a, string>) -> HttpRequest -> Choice<'a, string>)
所以,我的类型不匹配,但我不太确定如何让这些匹配。
这个例子是不是已经过时了?有什么想法可以让这个例子编译和运行吗?
我正在运行 Visual Studio 2015 的 RC 版本
谢谢