Chris Stryczynski

Software Developer / Consultant

How to modify a dynamic nested YAML object with Haskell

So Haskell has an awesome YAML library (based off the famous JSON library), however I’m not sure if there is a ‘Lens’ binding for it - like the aeson library, I’m also not that familiar with lens, so thought I’d just do this manually.

I didn’t find any solution online so I’m posting it here.

I couldn’t use the usual toYAML / fromYAML as the YAML would be dynamic.

The above can be used with createDeployment deploymentConfig "test" and will modify the below:

metadata:
  name: diyapp
  labels:
    appId: thisHasToBeReeplaced

To

metadata:
  name: diyapp
  labels:
    appId: test