pqnet
pqnet

Reputation: 6588

Why are f# custom operation not allowed into control flow statement?

Using a custom operation of a f# computation expression inside any control flow statement fails typechecking with

error FS3086: A custom operation may not be used in conjunction with 'use',
'try/with', 'try/finally', 'if/then/else' or 'match' operators within this
computation expression

Why is this not allowed? What is in custom operation that does not allow rewriting this:

expr {
    if a then
        custom (x)
    else
        return (y)
}

to something like this:

expr {
    return! 
        if a then
            expr { custom (x) }
        else
            expr { return (y) }
}

Upvotes: 8

Views: 821

Answers (0)

Related Questions