GithubHelp home page GithubHelp logo

Comments (9)

milessabin avatar milessabin commented on June 25, 2024

How deep is the nesting? Also how are you constructing them? Is this using Nat indices?

from shapeless.

johanstenberg92 avatar johanstenberg92 commented on June 25, 2024

Hi, The nesting is only 1 step deep, and I construct them as follows:

case class A(str: String)
case class B(a: A)

val strLens = lens[B] >> 'a >> 'str

What is Nat indices?

Cheers

from shapeless.

milessabin avatar milessabin commented on June 25, 2024

OK, thanks. Are you able to put together a simple source file which demonstrates the compile time blow up?

"Nat indices" refers to the earlier mechanism of specifying lenses by positional offsets of fields (ie. lens[Foo] >> _1 >> _2, etc.).

from shapeless.

johanstenberg92 avatar johanstenberg92 commented on June 25, 2024

Here: http://pastebin.com/cNnuk8sg

Cheers

from shapeless.

milessabin avatar milessabin commented on June 25, 2024

Thanks for that. I needed to add case class GeoKeyDirectory() to get it to compile successfully. When it did it took 176 seconds for that file on it's own on my laptop ... is that comparable to what you're seeing with that file in isolation?

from shapeless.

johanstenberg92 avatar johanstenberg92 commented on June 25, 2024

Hi, sorry I'm a scala rookie I must had forgot that class. It took me more time but then the file was in a large project and my computer is a bit slow.

However it's still way to long, any idea what would speed it up?

from shapeless.

milessabin avatar milessabin commented on June 25, 2024

Yes, I completely agree.

I'm fairly sure that this is the same issue which is at play in #50, which is due to compile time overheads in the use of singleton-typed Strings as field selectors. It's not clear to me at the moment if this is a Scala compiler issue or something which is fixable in shapeless.

A workaround is to use Nat field indices, ie.,

import shapeless.nat._

val artistLens = metaDataTagsLens >> _0
val copyrightLens = metaDataTagsLens >> _1
val dateTimeLens = metaDataTagsLens >> _2
val computerLens = metaDataTagsLens >> _3
val imageDescLens = metaDataTagsLens >> _4
val makerLens = metaDataTagsLens >> _5
val modelLens = metaDataTagsLens >> _6
val softwareLens = metaDataTagsLens >> _7

But this is, of course, very fragile if you are likely to reorder the elements of your case classes.

from shapeless.

johanstenberg92 avatar johanstenberg92 commented on June 25, 2024

Okay, I'm trying out monacle now, if that doesn't work out I will switch back to shapeless with Nat field indices. Thank you for the quick response by the way!

Cheers

from shapeless.

milessabin avatar milessabin commented on June 25, 2024

Fixed in d4c3c71.

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.