计算表达凹痕混乱

发布于 2025-02-09 07:23:40 字数 2060 浏览 1 评论 0原文

我显然不了解计算表达中的缩进(我通常是地图/绑定的人)。

此代码编译

        seq {
            for concept in model.EsWondomainmodelconcepts do
                let attLookup = seq {
                    for att in concept.Attributes.EsWondomainmodelattributes do
                        for tag in (att.XmlTag |> Option.toArray) do
                            for mult in (att.Multiplicity.EspEnumeration.Identificationdisplaystring.String |> Option.toArray) do
                                (tag,multiplicityToRelationshipCardinality mult)
                } 
                (concept.XmlTag, attLookup |> Map.ofSeq)
        }
        |> Map.ofSeq
        |> WOnSchemaRawData

这并不是

        seq {
            for concept in model.EsWondomainmodelconcepts do
                let attLookup = seq { // FS3118 on this line
                    for att in concept.Attributes.EsWondomainmodelattributes do
                        for tag in (att.XmlTag |> Option.toArray) do
                            for mult in (att.Multiplicity.EspEnumeration.Identificationdisplaystring.String |> Option.toArray) do
                                (tag,multiplicityToRelationshipCardinality mult)
                } |> Map.ofSeq // FS0588 here
                (concept.XmlTag, attLookup)
        }
        |> Map.ofSeq
        |> WOnSchemaRawData

“让attlookup = ....” comply

Severity    Code    Description Project File    Line    Suppression State
Error   FS3118  Incomplete value or function definition. If this is in an expression, the body of the expression must be indented to the same column as the 'let' keyword.  

和1st“ |> map.ofseq”行clock offe

Severity    Code    Description Project File    Line    Suppression State
Error   FS0588  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    

I clearly don't understand indentation in computational expression (I'm usually a map/bind sort of person).

This code compiles

        seq {
            for concept in model.EsWondomainmodelconcepts do
                let attLookup = seq {
                    for att in concept.Attributes.EsWondomainmodelattributes do
                        for tag in (att.XmlTag |> Option.toArray) do
                            for mult in (att.Multiplicity.EspEnumeration.Identificationdisplaystring.String |> Option.toArray) do
                                (tag,multiplicityToRelationshipCardinality mult)
                } 
                (concept.XmlTag, attLookup |> Map.ofSeq)
        }
        |> Map.ofSeq
        |> WOnSchemaRawData

this doesnt

        seq {
            for concept in model.EsWondomainmodelconcepts do
                let attLookup = seq { // FS3118 on this line
                    for att in concept.Attributes.EsWondomainmodelattributes do
                        for tag in (att.XmlTag |> Option.toArray) do
                            for mult in (att.Multiplicity.EspEnumeration.Identificationdisplaystring.String |> Option.toArray) do
                                (tag,multiplicityToRelationshipCardinality mult)
                } |> Map.ofSeq // FS0588 here
                (concept.XmlTag, attLookup)
        }
        |> Map.ofSeq
        |> WOnSchemaRawData

the line "let attLookup = ...." complains

Severity    Code    Description Project File    Line    Suppression State
Error   FS3118  Incomplete value or function definition. If this is in an expression, the body of the expression must be indented to the same column as the 'let' keyword.  

and the 1st "|> Map.ofSeq" complains

Severity    Code    Description Project File    Line    Suppression State
Error   FS0588  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    

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瑶笙 2025-02-16 07:23:40

我相信我理解这一点而无需与编译器尝试。我将说明一些简单的代码段所发生的事情。

允许这样做:

let x = seq { 1; 2;
    3 }

但是这是不允许的,这对我来说很有意义,为什么不允许:

let x = seq { 1; 2;
    3 }
    |> Seq.sum

这对我也很有意义:

let x =
    seq { 1; 2;
        3 }
    |> Seq.sum

所以我怀疑您可以像最后一段一样格式化代码,这将是好的。

I believe I understand this without trying it out with a compiler. I will illustrate what I think happens with some simpler code snippets.

This is allowed:

let x = seq { 1; 2;
    3 }

But this is not allowed, and it makes sense to me why not:

let x = seq { 1; 2;
    3 }
    |> Seq.sum

This is allowed, which also makes sense to me:

let x =
    seq { 1; 2;
        3 }
    |> Seq.sum

So I suspect you can format the code as in the last snippet, and it'll be good.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文