Coder Social home page Coder Social logo

ByteString.Char8 encoder about waargonaut HOT 6 OPEN

hasufell avatar hasufell commented on July 3, 2024
ByteString.Char8 encoder

from waargonaut.

Comments (6)

mankyKitty avatar mankyKitty commented on July 3, 2024

I'm not sure that's really "issue" worthy, but I would happily accept a PR for such a thing. 👍

import qualified Data.ByteString.Char8 as B8

encodeByteStringChar8 :: Applicative f => Encoder f B8.ByteString
encodeByteStringChar8 = B8.unpack >$< string

:)

from waargonaut.

hasufell avatar hasufell commented on July 3, 2024

Well, this converts to string. I was wondering if there could be a more efficient low-level encoder.

from waargonaut.

mankyKitty avatar mankyKitty commented on July 3, 2024

Quite possible, as ByteString.Char8 is limited to the latin1 charset which is a subset of what the JSON RFC allows. So you could see how well it goes to just drop it directly into the encoded structure.

Have you encountered any efficiency issues with Waargonaut?

from waargonaut.

hasufell avatar hasufell commented on July 3, 2024

Have you encountered any efficiency issues with Waargonaut?

Not really, it's my first time trying to use it.

So you could see how well it goes to just drop it directly into the encoded structure.

Yeah, but the internal API is a bit complicated ;)

from waargonaut.

mankyKitty avatar mankyKitty commented on July 3, 2024

Not really, it's my first time trying to use it.

Phew and yay!

Yeah, but the internal API is a bit complicated ;)

Yeah... it is a bit.. ahem :<

Part of this is due to a slightly crazy adherence to the RFC for JSON. Hence the wacky level of detail in the string types etc. As well as being able to support round trip parsing & printing, which meant trying to find a way to remember where all the whitespace is, and what type of whitespace it is.

from waargonaut.

mankyKitty avatar mankyKitty commented on July 3, 2024

One option could be to change the type alias here https://github.com/qfpl/waargonaut/blob/master/src/Waargonaut/Types/JString.hs#L78 to be a sum type that is either the internal JString' representation or a narrower NonUnicode type... maybe:

data JString
  = JString' HeXDigit
  | NonUnicode Char8.ByteString

from waargonaut.

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.