Git Product home page Git Product logo

Comments (4)

milessabin avatar milessabin commented on May 22, 2024

Yes, I agree that this is a pain at the moment. Have you seen RecordType.like aka "type by example"?

It's far from perfect, but I think it helps a bit.

from shapeless.

milessabin avatar milessabin commented on May 22, 2024

I think this is now addressed via the new record type literals in shapeless 2.1.0 ... does this resolve the problem for you?

object TestExplicitRecordType {
  import shapeless._, labelled._, record._, syntax.singleton._

  object testF extends Poly1 {
    implicit def atFieldType[F, V](implicit wk: shapeless.Witness.Aux[F]) = at[FieldType[F, V]] {
      f => wk.value.toString
    }
  }

  type Error = Record.`"k1" -> String, "k2" -> Long`.T

  // That seems to work...
  val err1        = "k1" ->> "1" :: "k2" ->> 1L :: HNil
  val err2: Error = "k1" ->> "1" :: "k2" ->> 1L :: HNil

  testF(err1.head)  // OK
  testF(err2.head)  // OK
}

from shapeless.

jonifreeman avatar jonifreeman commented on May 22, 2024

Looks good, thanks!

from shapeless.

eugengarkusha avatar eugengarkusha commented on May 22, 2024

it would be great if record type literals could be written in multiple lines :

 type Error = Record.`
                       "k1" -> String,
                       "k2" -> Long
                    `.T

Is it generally possible?

from shapeless.

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.