Coder Social home page Coder Social logo

Comments (5)

NorfairKing avatar NorfairKing commented on May 19, 2024

@soenkehahn You'd have to write your own decoder, but I think it's possible because we know all the fields statically.

from autodocodec.

soenkehahn avatar soenkehahn commented on May 19, 2024

Thanks for the reply! Are you saying it's possible for me to implement this without modifying autodocodec? If yes, I'm not sure what you mean by "write your own decoder". Codecs seem to encompass both encoders and decoders, and I'm not sure how I would go about writing my own decoder while using a provided decoder, if that makes sense. Any pointers appreciated!

from autodocodec.

NorfairKing avatar NorfairKing commented on May 19, 2024

@soenkehahn Sorry I've not been very clear. It's easy for me to forget context that I only have because I wrote this code.

A codec is just a value that represents an idea.
This function does the decoding:

-- | Parse via a general codec.
--
-- You probably won't need this. See 'eitherDecodeViaCodec', 'parseJSONViaCodec' and 'parseJSONVia' instead.
parseJSONContextVia :: Codec context void a -> context -> JSON.Parser a
parseJSONContextVia codec_ context_ =
modifyFailure (\s -> if '\n' `elem` s then "\n" ++ s else s) $
go context_ codec_

You could write your own version to warn or reject on unknown fields.

from autodocodec.

Icelandjack avatar Icelandjack commented on May 19, 2024

Is it possible to add support for this (decoder?) to the library so that users can configure this behaviour. I know you have already closed this but would you accept a pull request?

from autodocodec.

NorfairKing avatar NorfairKing commented on May 19, 2024

@Icelandjack I think my "closed" communication was not clear. I just meant that I haven't planned to add it myself. A PR would be welcome!

from autodocodec.

Related Issues (19)

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.