GithubHelp home page GithubHelp logo

Comments (6)

elliottt avatar elliottt commented on August 16, 2024

I like the idea of doing the chunked representation. I don't really see any problem with exposing both a chunked version of putListOf/getListOf, in addition to one that picks a sane default value. If you're interested in writing the patch, I'd be happy to take the contribution :)

from cereal.

Gabriella439 avatar Gabriella439 commented on August 16, 2024

I'd be happy to write up the patch. Just give me a while because I need to familiarize myself with the cereal internals some more first.

from cereal.

elliottt avatar elliottt commented on August 16, 2024

You should be able to write it as something that makes iterated calls to putListOf/getListOf as a primitive, looping over its input and splitting at the chunk boundary using splitAt.

putChunkedListOf :: Int -> Putter a -> Putter [a]
putChunkedListOf clen f = loop
  where
  loop xs = do
    let (as,bs) = splitAt clen xs
    putListOf f as
    unless (null bs) (loop bs)

from cereal.

Gabriella439 avatar Gabriella439 commented on August 16, 2024

Yeah, I wasn't going to do it exactly the way I wrote it. That was just
something I threw together for an example. Hand-writing the chunking
would also let me inline the code for marking the last chunk.

On 08/20/2012 02:19 PM, Trevor Elliott wrote:

You should be able to write it as something that makes iterated calls
to putListOf/getListOf as a primitive, looping over its input and
splitting at the chunk boundary using splitAt.

putChunkedListOf :: Int -> Putter a -> Putter [a]
putChunkedListOf clen f = loop
where
loop xs = do
let (as,bs) = splitAt clen xs
putListOf f as
unless (null bs) (loop bs)


Reply to this email directly or view it on GitHub
#6 (comment).

from cereal.

elliottt avatar elliottt commented on August 16, 2024

(I'm closing this as it seems like you'll submit a pull request when the feature is ready :)

from cereal.

Gabriella439 avatar Gabriella439 commented on August 16, 2024

Yeah, I will submit a pull request when it is ready.

from cereal.

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.