1

I am creating a DSL for C4 model diagrams. 1st stab at it is here I decided it would make more sense to separate software concepts and diagram. What this means is the position on the canvas only need be assigned when creating the diagram.

So when I tried adding position to the custom operation arguments I cannot figure out how to use it in the computation expression.

The new builder looks like this:

type SystemLandscapeDiagramBuilder internal (scope, desc, size) =
    member __.Yield(_) : SystemLandscapeDiagram = 
        SystemLandscapeDiagram.init scope desc size

    [<CustomOperation("user")>]
    member __.User(diagram, user, pos) : SystemLandscapeDiagram =
        diagram |> SystemLandscapeDiagram.addPerson user pos

The compiler error is This control construct may only be used if the computation expression builder defines a 'For' method

Is it possible to have multiple arguments? Ideas on what I am doing wrong?

Devon Burriss
  • 2,497
  • 1
  • 19
  • 21
  • The error is about the `Yield` method, not about multiple parameters. – Fyodor Soikin Sep 27 '18 at 20:31
  • @FyodorSoikin thanks for commenting but could you give more information on why it is Yield? It works if I remove the `pos` argument from `User`(working code is linked and tagged in the question). Still learning how the computation expression methods interact. This worked: https://github.com/dburriss/Fucturizr/blob/v0.0/src/Fucturizr.Core/Core.fs#L345 – Devon Burriss Sep 27 '18 at 21:25

0 Answers0