Giter Club home page Giter Club logo

Comments (5)

markehammons avatar markehammons commented on June 4, 2024

Matthieu, I think this does what you want:

implicit def cPickler[T <: X] = new CustomPickler[T]

from pickling.

heathermiller avatar heathermiller commented on June 4, 2024

We don't have much for documentation (yet) of scala-pickling (besides an academic paper which covers some of these things, but is definitely not ideal for developers). Apologies– comprehensive documentation is on the way.

An important detail that you might not know is that SPickler[T] is meant to pickle only objects of type T, but not subtypes of T.

That means that when you define:

    implicit def cPickler = new CustomPickler[X]

A CustomPickler[X] is introduced in the implicit scope, but CustomPicklers for any of X's subtypes are not introduced into implicit scope. So, @markehammons is correct– the easiest way, when supplying your own custom picklers, and dealing with subtypes, is to be explicit that your custom pickler is also suitable for subtypes of X:

    implicit def cPickler[T <: X] = new CustomPickler[T]

from pickling.

heathermiller avatar heathermiller commented on June 4, 2024

Could you let us know if this clarifies things/solves your problem?

from pickling.

mathieuleclaire avatar mathieuleclaire commented on June 4, 2024

It clarifies this point yes, thanks. I stay tuned for more documentation then !

from pickling.

heathermiller avatar heathermiller commented on June 4, 2024

Awesome- thanks, closing this then. :)

from pickling.

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.