{"action":"created","issue":{"url":"https://api.github.com/repos/kcsongor/generic-lens/issues/13","repository_url":"https://api.github.com/repos/kcsongor/generic-lens","labels_url":"https://api.github.com/repos/kcsongor/generic-lens/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/kcsongor/generic-lens/issues/13/comments","events_url":"https://api.github.com/repos/kcsongor/generic-lens/issues/13/events","html_url":"https://github.com/kcsongor/generic-lens/issues/13","id":254864050,"number":13,"title":"Performance guarantees?","user":{"login":"nomeata","id":148037,"avatar_url":"https://avatars2.githubusercontent.com/u/148037?v=4","gravatar_id":"","url":"https://api.github.com/users/nomeata","html_url":"https://github.com/nomeata","followers_url":"https://api.github.com/users/nomeata/followers","following_url":"https://api.github.com/users/nomeata/following{/other_user}","gists_url":"https://api.github.com/users/nomeata/gists{/gist_id}","starred_url":"https://api.github.com/users/nomeata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nomeata/subscriptions","organizations_url":"https://api.github.com/users/nomeata/orgs","repos_url":"https://api.github.com/users/nomeata/repos","events_url":"https://api.github.com/users/nomeata/events{/privacy}","received_events_url":"https://api.github.com/users/nomeata/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2017-09-03T09:38:07Z","updated_at":"2017-09-03T16:34:48Z","closed_at":null,"author_association":"NONE","body":"At the IFL talk, @kcsongor mentioned that these generic lenses optimize down to what one would write by hand. That would be amazing, but I cannot reproduce it. Here is my example:\r\n\r\n```\r\n{-# LANGUAGE RankNTypes, DeriveGeneric, TypeApplications, DataKinds #-}\r\nmodule GenericLens where\r\n\r\nimport GHC.Generics\r\nimport Data.Generics.Product\r\n\r\ndata Record = MkRecord { fieldA :: Int\r\n                       , fieldB :: Bool\r\n                       } deriving Generic\r\n\r\ntype Lens' s a = forall f. Functor f => (a -> f a) -> s -> f s\r\n\r\nfieldALensManual :: Lens' Record Int\r\nfieldALensManual f (MkRecord a b) = (\\a -> MkRecord a b) <$> f a\r\n\r\nfieldALensGeneric :: Lens' Record Int\r\nfieldALensGeneric = field @\"fieldA\"\r\n```\r\n\r\nI compile this with\r\n```\r\nghc-8.2 -O2 GenericLens.hs  -ddump-simpl\r\n```\r\nand I get somewhat nice Core for the manual lens:\r\n```\r\nfieldALensManual\r\n  = \\ (@ (f_a5HR :: * -> *))\r\n      ($dFunctor_a5HT :: Functor f_a5HR)\r\n      (f1_a1Th :: Int -> f_a5HR Int)\r\n      (ds_d6PM :: Record) ->\r\n      case ds_d6PM of { MkRecord a_a1Ti b_a1Tj ->\r\n      fmap\r\n        @ f_a5HR\r\n        $dFunctor_a5HT\r\n        @ Int\r\n        @ Record\r\n        (\\ (a1_a1Tk :: Int) -> GenericLens.MkRecord a1_a1Tk b_a1Tj)\r\n        (f1_a1Th a_a1Ti)\r\n      }\r\n```\r\nbut very large Core for the generic lens, which I will not even paste here. But there is a lot of stuff about Generics still around.\r\n\r\nUnder what conditions, if any, do the generic lenses optimize to the “real” thing?"},"comment":{"url":"https://api.github.com/repos/kcsongor/generic-lens/issues/comments/326815495","html_url":"https://github.com/kcsongor/generic-lens/issues/13#issuecomment-326815495","issue_url":"https://api.github.com/repos/kcsongor/generic-lens/issues/13","id":326815495,"user":{"login":"kcsongor","id":313596,"avatar_url":"https://avatars3.githubusercontent.com/u/313596?v=4","gravatar_id":"","url":"https://api.github.com/users/kcsongor","html_url":"https://github.com/kcsongor","followers_url":"https://api.github.com/users/kcsongor/followers","following_url":"https://api.github.com/users/kcsongor/following{/other_user}","gists_url":"https://api.github.com/users/kcsongor/gists{/gist_id}","starred_url":"https://api.github.com/users/kcsongor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kcsongor/subscriptions","organizations_url":"https://api.github.com/users/kcsongor/orgs","repos_url":"https://api.github.com/users/kcsongor/repos","events_url":"https://api.github.com/users/kcsongor/events{/privacy}","received_events_url":"https://api.github.com/users/kcsongor/received_events","type":"User","site_admin":false},"created_at":"2017-09-03T16:34:48Z","updated_at":"2017-09-03T16:34:48Z","author_association":"OWNER","body":"I was looking at the core by hand and GHC indeed recognises the equivalence by rewriting to a `generic = handwritten`  form - my understanding is that this is exactly what ghc-proofs is looking for?"}}
{"actor":{"display_login":"kcsongor"}}