F# 无法定义计算表达式“自定义”;条件“;操作人员

F# 无法定义计算表达式“自定义”;条件“;操作人员,f#,computation-expression,custom-operator,F#,Computation Expression,Custom Operator,在下面的代码中,我很难给出条件的定义。希望有一个例子和见解: // a computation expression builder class type Builder() = . . . [<CustomOperation( "condition", MaintainsVariableSpaceUsingBind = true )>] member this.Condition(p, [<ProjectionParame

在下面的代码中,我很难给出
条件
的定义。希望有一个例子和见解:

// a computation expression builder class
type Builder() =
    .
    .
    .

    [<CustomOperation( "condition",
      MaintainsVariableSpaceUsingBind = true )>]
    member this.Condition(p, [<ProjectionParameter>] b) = 
        condition p b

let attemp = AttemptBuilder()

let test =
    attempt { let x, y = exp1, exp2
              condition booleanExpr(x, y)   
              return (x, y) }
//计算表达式生成器类
类型生成器()=
.
.
.
[]
成员。条件(p,[]b)=
条件p-b
设attemp=attempbuilder()
试一试=
尝试{设x,y=exp1,exp2
条件布尔表达式(x,y)
返回(x,y)}
我假设
b
是隐式的
(funx,y->booleanExpr(x,y))
。术语
booleanExpr(x,y)
只是一个涉及
x
y
的布尔表达式,发现它:

let condition p guard = ( fun () ->
    match p() with
    | Some x when guard x -> Some x
    | _ -> None )
找到它:

let condition p guard = ( fun () ->
    match p() with
    | Some x when guard x -> Some x
    | _ -> None )

你想在这里实现什么?还有,看,就是这个。。。在Expert F#4.0的第475页上,您可以看到一个自定义条件运算符替换
的示例,如果
/
那么
。值
条件
没有明确定义。您在这里试图实现什么?还有,看,就是这个。。。在Expert F#4.0的第475页上,您可以看到一个自定义条件运算符替换
的示例,如果
/
那么
。值
条件
没有明确定义。