addCartographerMetadata :: FilePath -> Q Exp
addCartographerMetadata filename = do
  dotStr <- readDot filename
  addMetadata <- newName "addMetadata"
  instanceConfig <- newName "instanceConfig"
  metadata <- newName "metadata"

  
  {-
    Build and return a let expression that looks like this:

      let addMetadata instanceConfig@InstanceConfig {
                instanceMetadata = metadata
              } =
            instanceConfig {
                instanceMetadata = insert "cartography" dotStr metadata
              }
      in addMetadata
  -}

  return $ LetE [
      FunD addMetadata [Clause [AsP
          instanceConfig
          (RecP 'InstanceConfig [('instanceMetadata, VarP metadata)])
        ]
        (NormalB (
            RecUpdE (VarE instanceConfig) [('instanceMetadata,
                AppE
                  (AppE
                      (AppE (VarE 'insert) (LitE (StringL "cartography")))
                      dotStr
                    )
                  (VarE metadata)
              )]
          ))
        []
      ]
    ] (VarE addMetadata)
addCartographerMetadata :: FilePath -> Q Exp
addCartographerMetadata filename = do
  dotStr <- readDot filename
  addMetadata <- newName "addMetadata"
  instanceConfig <- newName "instanceConfig"
  metadata <- newName "metadata"

  
  {-
    Build and return a let expression that looks like this:

      let addMetadata instanceConfig@InstanceConfig {
                instanceMetadata = metadata
              } =
            instanceConfig {
                instanceMetadata = insert "cartography" dotStr metadata
              }
      in addMetadata
  -}

  return $ LetE [
      FunD addMetadata [Clause [AsP
          instanceConfig
          (RecP 'InstanceConfig [('instanceMetadata, VarP metadata)])
        ]
        (NormalB (
            RecUpdE (VarE instanceConfig) [('instanceMetadata,
                AppE
                  (AppE
                      (AppE (VarE 'insert) (LitE (StringL "cartography")))
                      dotStr
                    )
                  (VarE metadata)
              )]
          ))
        []
      ]
    ] (VarE addMetadata)
addCartographerMetadata filename = do
  dotStr <- readDot filename
  addMetadata <- newName "addMetadata"
  instanceConfig <- newName "instanceConfig"
  metadata <- newName "metadata"

  
  {-
    Build and return a let expression that looks like this:

      let addMetadata instanceConfig@InstanceConfig {
                instanceMetadata = metadata
              } =
            instanceConfig {
                instanceMetadata = insert "cartography" dotStr metadata
              }
      in addMetadata
  -}

  return $ LetE [
      FunD addMetadata [Clause [AsP
          instanceConfig
          (RecP 'InstanceConfig [('instanceMetadata, VarP metadata)])
        ]
        (NormalB (
            RecUpdE (VarE instanceConfig) [('instanceMetadata,
                AppE
                  (AppE
                      (AppE (VarE 'insert) (LitE (StringL "cartography")))
                      dotStr
                    )
                  (VarE metadata)
              )]
          ))
        []
      ]
    ] (VarE addMetadata)