错误:FS0010表达式中的意外标识符。在此之前或之前预期的不完整结构化构造或其他标记

时间:2019-12-05 08:50:43

标签: f#

| 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)
             ()
         }
     ()

     //Do something with the `message` value specific to the target
     //you are creating.

     //Don't put `use` statements in here; you need to dispose them before
     //recursing below.

     //This is a simple acknowledgement using unit as the signal
    ack *<= () (* LHS: the ACK is a unit sent to `ack` *) >>= fun () ->
                (* RHS (above): the callback after the ACK is done *)
    loop { state = not state.state } // recurse

此行有错误

ack *<= () (* LHS: the ACK is a unit sent to `ack` *) >>= fun () ->

错误:FS0010表达式中的意外标识符。在这一点或其他标记之前或之前预期的不完整结构化构造。

1 个答案:

答案 0 :(得分:1)

我尝试从Noop.fs in Logary中获取代码,并将您所做的更改粘贴到与Log大小写匹配的模式匹配大小写的位置。

由于代码中的缩进问题,我遇到了与您报告的错误相同的错误。特别是,带有ack *<= ()的行比定义两个助手功能的带有let的行少一个空间。在ack和下面的行之前添加一个额外的空格可解决此问题。

如果您从代码中删除几行,则可以清楚地看到这一点:

  let CreateEventSourcingConnection() =
      task {
          return connection
      }

  let AddEventToStreamAsync (connection: IEventStoreConnection) streamName eventName message =
      task {
          ()
      }
  ()
  //This is a simple acknowledgement using unit as the signal
 ack *<= () (* LHS: the ACK is a unit sent to `ack` *) >>= fun () ->
            (* RHS (above): the callback after the ACK is done *)
 loop { state = not state.state } // recurse