Giter Site home page Giter Site logo

Comments (7)

dcoutts avatar dcoutts commented on August 16, 2024

We can do this by decoding the Tokens to a Term and pretty printing the Term in CBOR syntax.

The testsuite already has a function diagnosticNotation :: Term -> String that produces the CBOR syntax (though it's for a type from the reference impl so some changes would be needed).

So yes, this should be straightforward and indeed useful. Perhaps we should make that the show instance for Encoding.

from cborg.

arianvp avatar arianvp commented on August 16, 2024

Something like: http://cbor.me/ ?

Which prints out these kind of useful messages:

a1       # map(1)
   61    # text(1)
      61 # "a"
   83    # array(3)
      01 # unsigned(1)
      03 # unsigned(3)
      04 # unsigned(4)

Or do you mean showing the json-like representation of an encoding?

{"a": [1, 3, 4]}

from cborg.

thoughtpolice avatar thoughtpolice commented on August 16, 2024

Why not both! We could have a .Pretty module with multiple functions! :)

from cborg.

dcoutts avatar dcoutts commented on August 16, 2024

I meant the latter form, which is informally specified in the CBOR spec, and which we already generate in the tests to compare to the reference test vectors.

from cborg.

axman6 avatar axman6 commented on August 16, 2024

I started implementing this, but got stuck when trying to use FlatTerm instead of Encoding directly. I'll give it another go this week if I find time. (Edit: Removed the useless code that was here to reduce noise)

from cborg.

axman6 avatar axman6 commented on August 16, 2024

Obviously this is missing the hex representation, which should be easier to produce with Encoding.

from cborg.

thoughtpolice avatar thoughtpolice commented on August 16, 2024

Closed by c1cafbe. We'll do future work in other tickets if necessary.

from cborg.

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.