We want to create a DSL in Scala where you can declaratively list the ingredients that a product consist of. These ingredients can consist of for example "Create product a", "Create product b", "Send mail". The ingredients can depend on each other (e.g., "mail" can only be send once both product a and product b are created). The goal is that the definition of the ingredients does not include imperative information. The parser of the DSL needs to determine the correct execution order based on for example types.
So for example:
"CompletedProduct" consists of { Mail, ProductA, ProductB }
should result in ProductA
and ProductB
being executed first (preferably sequentially, but this is not necessary in a first step), and once this is finished Mail
should be executed and a mail should be send.
What are possible ways to accomplish such a DSL that determined an execution plan?