`GHC.Generics.Lens` is weak and slow compared to `Data.Data.Lens` #114

Closed
ekmett opened this Issue Nov 23, 2012 · 8 comments

Projects

None yet

4 participants

@ekmett
Owner
ekmett commented Nov 23, 2012

GHC.Generics.Lens should expose uniplate, template, and biplate analogues, not just tinplate.

Right now GHC.Generics.Lens is fairly crippled compared to Data.Data.Lens.

It would be informative to:

  • Remove the need for Typeable in the GHC.Generics.Lens code, reverting to the use of the Generics Datatype class as appropriate.
  • Duplicate the reasoning from Data.Data.Lens that lets that code avoid traversing portions of the structure unnecessarily. Unlike Data.Data.Lens this can make more exacting judgments without having to "guess wrong" once first.
@ekmett
Owner
ekmett commented Nov 23, 2012

We should also add upon and whatver uponTheDeep variant to GHC.Generics.Lens when we get the chance.

@dag
Collaborator
dag commented Dec 1, 2012

Sounds like good ideas for sake of completeness, but I'm wondering if there are any benefits to supporting Generic in lens at all? Generic is great for implementing generically derivable type classes, but maybe Data is simply better suited for the kind of generic programming lens does? Any downsides to the Data/Typeable constraints as opposed to Generic? Both are derivable with GHC anyways ...

@ekmett
Owner
ekmett commented Dec 1, 2012

GHC.Generics has a better story for dealing with changing types and can deal, potentially, with polymorphic recursion in ways Data cannot.

In theory more static information could be available to the hit-map compiler in Data.Data.Lens in the GHC.Generics version as well, which might enable it to out-perform its competitor -- but I'm not holding my breath.

@dag
Collaborator
dag commented Dec 1, 2012

Cool!

@ekmett
Owner
ekmett commented Dec 1, 2012

Up until now to deal with polymorphic recursion in Data I've had to use my own syb-extras package. Sadly, I was unable to interest the maintainer of syb in adding Data1. =(

@glguy
Collaborator
glguy commented Jul 5, 2016

"Fixed" in 4e01a13

@glguy glguy closed this Jul 5, 2016
@flip111
flip111 commented Dec 2, 2016

Might still be worth looking into at some point because GHC.Generics could be faster than Data.Data, see ndmitchell/uniplate#11 (comment)

@glguy
Collaborator
glguy commented Dec 2, 2016

Not every use of Data is appropriate for use with GHC.Generics. The speed up isn't magical and relies on things being able to be determined at compile time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment