此';让';未完成,F#错误,尽管从函数返回值
错误:此';让';未完成,F#错误,尽管从函数返回值,f#,pattern-matching,let,F#,Pattern Matching,Let,错误: | Log (message, ack) -> let CreateEventSourcingConnection() = task { let connection = let ipEndPoint = IPEndPoint(IPAddress.Loopback, 1113) EventStoreConnection
| Log (message, ack) ->
let CreateEventSourcingConnection() =
task {
let connection =
let ipEndPoint = IPEndPoint(IPAddress.Loopback, 1113)
EventStoreConnection.Create(ipEndlPoint)
do! connection.ConnectAsync()
return connection
}
let AddEventToStreamAsync (connection: IEventStoreConnection) streamName eventName message =
task {
let serializedEventData =
message
|> JsonConvert.SerializeObject
|> Encoding.UTF8.GetBytes
let event = EventData(Guid.NewGuid(), eventName, true, serializedEventData, null)
let! _ = connection.AppendToStreamAsync(streamName, int64 ExpectedVersion.Any, event)
()
}
在定义这些函数之后,我尝试调用它们。我也检查了我的缩进,我想应该没问题。我知道我需要从函数中返回值,但我想我已经这样做了。我怀疑(不知道是哪个let
语句导致了错误)您需要从模式匹配中返回某些内容(即|Log(message,ack)->
之后的部分)
如果不需要返回任何内容,可以在末尾返回
()
,缩进级别与两个外部的let
s相同,但请注意,模式匹配的所有分支都需要返回相同的类型。在AddEventToStreamAsync的末尾-是否可以尝试“return()”而不是“()”?哪个let
语句导致错误?
The block following this 'let' is unfinished. Every code block is an expression and must have a result. 'let' cannot be the final code element in a block. Consider giving this block an explicit result.