docs: def dump(d, fmt='json', stream=None):
      """Serialize structured data into a stream in JSON, YAML, or LHA format.
      If stream is None, return the produced string instead.
  
      Parameters:
      - fmt: should be 'json' (default), 'yaml', or 'lha'
      - stream: if None, return string
      """
      if fmt == 'json':
          return _dump_json(d, stream=stream)
      elif fmt == 'yaml':
          return yaml.dump(d, stream)
      elif fmt == 'lha':
          s = _dump_lha(d)
          if stream is None:
              return s
          else:
              return stream.write(s)