by iainmerrick · 2y ago · 0 comments
[0] https://fsharpforfunandprofit.com/posts/designing-with-types...
It might work in a language with linear types or some concept of ownership. Execute() would take ownership of the Resolver and prevent it being called again.
It wouldn't make much sense. The whole point is not needing a new one, but reusing the record.
The given example looks like a Builder pattern. Although that name smells strongly of Java, so Go users might prefer to avoid it. :)
I wanted to express that having functions
f(a) -> b {}
f(b) -> c {}
f(c) -> d {}
...
would be quite trivial.I would say that the whole point of the builder pattern is _not_ having an ordering of the "chained" functions.
That seems like the same thing as the example in the original post.