Coder Social home page Coder Social logo

Update Issue type about issue-wanted HOT 6 CLOSED

kowainik avatar kowainik commented on June 3, 2024
Update Issue type

from issue-wanted.

Comments (6)

chshersh avatar chshersh commented on June 3, 2024 1

@rashadg1030 We don't need FromJSON instance. Regarding the problem with ToJSON instance: you can store a plain list of values inside the Issue data type and wrap it in PGArray only in the ToRow/FromRow instances. This means that you cannot derive those instances automatically, you need to write them manually. But what can be done... You either need to write manual JSON or Row instances. And let's not have orphan instances. Manual wrapping and unwrapping is better for the maintainability.

from issue-wanted.

rashadg1030 avatar rashadg1030 commented on June 3, 2024

Is there a ToRow/FromRow instance for type [a], or do I have to roll my own? The Issue type has a labels :: [Text] field. How do we get this to an SQL array?

from issue-wanted.

rashadg1030 avatar rashadg1030 commented on June 3, 2024

https://www.stackage.org/haddock/nightly-2019-06-27/postgresql-simple-0.6.2/Database-PostgreSQL-Simple-Types.html
I think I found something newtype PGArray a

from issue-wanted.

chshersh avatar chshersh commented on June 3, 2024

@rashadg1030 Yes, for arrays you need to use PGArray newtype

from issue-wanted.

rashadg1030 avatar rashadg1030 commented on June 3, 2024

@chshersh Okay so Issue now has a PGArray Text field. I have a ToJSON instance for Issue. I'm trying to roll the FromJSON instance, but I was thinking if we even need an instance because we're using the github api. Maybe we still need it for something else though

from issue-wanted.

rashadg1030 avatar rashadg1030 commented on June 3, 2024
instance (ToJSON a) => ToJSON (PGArray a) where
  toJSON :: PGArray a -> Value 
  toJSON = toJSON . fromPGArray

I get an orphan instance warning. It's telling me to either:

 move the instance declaration to the module of the class or of the type, or
 wrap the type with a newtype and declare the instance on the new type.

from issue-wanted.

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.