GithubHelp home page GithubHelp logo

Comments (7)

perlpunk avatar perlpunk commented on June 14, 2024

That's expected behaviour. Merge keys only work for hashes.

from yaml-pp-p5.

ArcticSnowman avatar ArcticSnowman commented on June 14, 2024

https://yaml.org/type/merge.html

 If the value associated with the merge key is a sequence, then this sequence is expected to contain mapping nodes and each of these nodes is merged in turn according to its order in the sequence.

So an array of scalars can't be merge? That would be nice if it was possible.

from yaml-pp-p5.

perlpunk avatar perlpunk commented on June 14, 2024
<<: [ *node1 ]

here the "value associated with the merge key" is already a sequence. But the actual nodes in that sequence have to be mappings.
Merging sequences is not possible with this feature.

There are ideas how to make that possible in the next YAML version.
But also I might add a custom tag to YAML::PP that allows merging sequences.

from yaml-pp-p5.

ArcticSnowman avatar ArcticSnowman commented on June 14, 2024

Ah, that sequence..

from yaml-pp-p5.

ArcticSnowman avatar ArcticSnowman commented on June 14, 2024

See https://metacpan.org/pod/YAML::LoadBundle for ideas..

from yaml-pp-p5.

perlpunk avatar perlpunk commented on June 14, 2024

I was rather thinking about using tags. The merge key for mappings is also basically a tag, it's just implicit.
Explicit it would be: !!merge <<: ...

Something like:

seq1: &s1 [a, b, c]
seq2: &s2 [d, e, f]
merged: !merge-seq [*s1, *s2]

Since YAML has tags, there's no need to use special named scalars and structures.

Edit: but yeah, options like deep merge for hashes and so on would also be nice.

from yaml-pp-p5.

ArcticSnowman avatar ArcticSnowman commented on June 14, 2024

Yeah I believe our LoadBundle pre-dates the merge feature in YAML. Might suggest to the authors of the LoadBundle to consider adding support for a "TAG" based approach as well as a custom key based approach.

from yaml-pp-p5.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.