Working with indeterminate/variable data types


I’m looking into using Dhall to generate YAML that Google Cloud Workflows can parse. One of the things I’m not sure how to handle is doing things with the result from steps returning parsed json. How would I handle something like this with Dhall, where I will know what I expect to be there but the result type will be different for every step?

Can I just create new data types and wrapper packages for each service? Is there any way I can have a function that generates the appropriate data structure but also “returns” a references that I can use later? Maybe writing a DSL in a full PL would be better than using Dhall for this since there are a lot of non-functional aspects of working with this service like loops. There are a bunch of yaml-driven services that work like this though, CI systems, Argo, etc, so it would be nice to use something like Dhall for all of them plus the boring config files.