【问题标题】:Error: FS0010 Unexpected identifier in expression. Expected incomplete structured construct at or before this point or other token错误:FS0010 表达式中有意外的标识符。预期在此点或之前的不完整结构化构造或其他标记
【发布时间】:2020-03-30 03:49:41
【问题描述】:
| 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 表达式中有意外的标识符。预计此时或之前的不完整结构化构造或其他标记。

【问题讨论】:

标签: f#


【解决方案1】:

我尝试从Noop.fs in Logary 获取代码并粘贴您的更改以代替匹配Log 案例的模式匹配案例。

由于代码中的缩进问题,我收到了与您报告的相同的错误。特别是,ack *&lt;= () 的行比定义两个辅助函数的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

【讨论】:

  • Diky moc。 :) 如果您也可以查看我的其他 F# 问题,我将不胜感激。
猜你喜欢
  • 2020-03-01
  • 2021-01-05
  • 1970-01-01
  • 1970-01-01
  • 2022-01-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多