Git Product home page Git Product logo

codec's People

Contributors

chpatrick avatar lysxia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codec's Issues

codec-0.1 does not compile

Citing from http://hydra.cryp.to/build/916656/log/raw:

Building codec-0.1...
Preprocessing library codec-0.1...

Data/Codec.hs:9:8:
    Could not find module ‘Data.Codec.Field’
    Use -v to see a list of the files searched for.

Data/Codec.hs:10:8:
    Could not find module ‘Data.Codec.Codec’
    Use -v to see a list of the files searched for.

Data/Codec.hs:11:8:
    Could not find module ‘Data.Codec.TH’
    Use -v to see a list of the files searched for.

Data/Codec.hs:12:8:
    Could not find module ‘Data.Codec.Tuple’
    Use -v to see a list of the files searched for.

Update README about constructor field ordering

The README reads:

You can serialize in any order you like, regardless of field order in the data type

But, sadly, that is no longer true with the Applicative+Profunctor approach.

(Sorry!)

Compatibility with GHC 8

I would like to use codec (a very nice package), but have already made the transition to GHC 8 which this library is currently not compatible with.

The fix is to add a wildcard between vs and cs at L81 of Data.Codec.TH.

Interestingly, the latest template-haskell version is compatible with base-4.7 up to 4.9; unfortunately that only goes as far as GHC 7.8, whereas you currently support GHC 7.6 too.

The simplest way to remain compatible seems to be to use CPP.

Types of f_1 and f_2 cannot be inferred

Trying to type

:t (,)
  $>> f_1 >-< pure ()
  >>> f_2 >-< pure 'a' :: (Applicative fr, Applicative fw) => Codec fr fw ((), Char)

results in some "could not deduce" errors

Could not deduce (Buildable ((), Char) y0)
Could not deduce (Field1 ((), Char) () (a0 -> b0 -> (a0, b0)) b1)
Could not deduce (Field2 ((), Char) Char b1 y0)

While an instance Field1 (a, b) a (a -> c -> (a, b)) (X -> c -> (a, b)) exists, it cannot be selected here because the compiler cannot first deduce that ((), Char) should be equal to (a0, b0) (fundeps would then take care of the rest).

Annotating (,) :: () -> Char -> ((), Char) makes the above typecheck, though this causes f_1 and f_2 to be rather annoying to use.

Making them regular functions would be a better fix IMO. Is there a reason why they are defined in typeclasses that I am missing?

ADTs example

I have figured out how to parse an ADT but am not sure how to serialize it well. Instead of the constructor being the initial function, a function that picks the constructor would be the starting function. However, I am not sure how to continue from there.

Using JSON:

data StringEncoded
  = Date Year Month Day
  | Money Currency Int

stringEncodedObjCodec :: JSONCodec StringEncoded
stringEncodedObjCodec = ???

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.