Giter Site home page Giter Site logo

Comments (5)

axman6 avatar axman6 commented on August 16, 2024

For an none wondering, the url is https://gist.github.com/ondrap/a0791fafcce466966699 somehow all the '.'s were removed.

Definitely looks like a strange big to me - is a list of n+1 elements the canonical way to represent sum types? Been a while since i've read the docs. Also is there no need for something to close the list?

from cborg.

ondrap avatar ondrap commented on August 16, 2024

It's one of the possible ways to do it - see https://github.com/well-typed/binary-serialise-cbor/blob/master/Data/Binary/Serialise/CBOR/Class.hs for the default instances. However what's fishy is that deserialise . serialise doesn't work, while deserialise . (force the list) . serialise works. I looked into the cbor sources and it seems to me that while quite dense with all those unsafe functions, it's still not as unsafe as to cause such behaviour.
BTW: it seems that the triggering point is serialising Integer with Text - what deserialised badly is the Integer. The Text value is probably causing the Integer to fall on some chunk boundary. My quickcheck tests didn't find any problem with other datatypes (might be harder to find).

from cborg.

ondrap avatar ondrap commented on August 16, 2024

I have updated the gist with another test case - it seems there is still some error as it incorrectly parses forced ByteString if the bytestring consist of 1-byte chunks. This testcase shows an error in binary-serialise-cbor though.

  • the deserialise . tokenize . serialise fails even when run in ghci; deserialise . serialise works correctly when run in ghci

from cborg.

ondrap avatar ondrap commented on August 16, 2024

Ok, so both of this is either a GHC bug or some bug inside binary-serialize-cbor touching something it shouldn't touch. When loaded in GHCi, this produces different results when run repeatedly:

filter (\(a,b) -> not b) (map (\i -> (i,chunkProp [VNum (-41), VTerms [T.pack (replicate i 'a')]])) [0..800])

from cborg.

ondrap avatar ondrap commented on August 16, 2024

I have fixed the problem, it seems to have no impact on performance. However, the accursedUnutterablePerformIO is available only in bytestring-0.10.6.0, the previous version had unsafeDupableIO. Does it make sense to build-depend on bytestring-0.10.6 and higher? I will try to add some test before doing a pull request.

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.