谁发明了代理传球和什么时候? [英] Who invented proxy passing and when?
问题描述
f(undefined :: T)
Kiselyov和Shan甚至在他们的经典论文中使用这种方法,它激发了反射
包。他们通过指出从不检查虚假价值来免除明显的丑陋。并且在 Data.Bits.finiteBitSize
中出现了一个稍微不那么丑陋的化身,它取得了一个它忽略的值来获得它的类型。
然后有人找出代理成语,并且一切都改变了。现在我们总是看到更加令人满意的
f(Proxy :: Proxy T)
(在标准代码中,GHC类型的应用程序是另一回事)。 出来吗?这首先出现在代码的某个地方,还是一篇论文?
TypeLevelReasoning (来自2013年4月的早期GHC提案)引用了 为Haskell提供促销作者Yorgey,Cretin,SPJ(2011年10月) 用课堂报废你的样板 Lammel,Jones(ICFP 2005) > b 在这里,我的谷歌搜索变得干燥起来。我似乎无法找到2005年论文的前奏。 Coda:Shachaf在该主题中的建议,通过使用 It seems that until recent years, the usual way to pass an extra type to a function was to do something like库
线程Proxy,new Typeable,and类型级别相等(原始海报Richard Eisenberg,许多最近的依赖Haskell工作背后的推动力)。该线程引用另一个库
线程代理和新类型(原始海报Shachaf Ben-Kiki),它是为了响应新类型
分支中的补丁而启动的。很难找到旧分支名称的记录以及他们指出哪些提交,但提交3d53407 PedroMagalhães似乎是该分支的压扁版本。事实上,它似乎是GHC中第一次提交 c $ c> data Proxy t = Proxy
类型的提交登录。艾森伯格稍后会将该类型移动到 Data.Proxy /Proxy.hsrel =noreferrer> commit 01aa22b 。 Proxy
的最终设计似乎是来自许多人的想法的集体合成。但是,我们可以在Magalhães的工作中找到对 Proxy
的学术参考,例如他的演讲正确的泛型编程(2012年10月)及其博客文章即将在GHC HEAD:poly-kinded Typeable(2012年11月)。我们可以将基础中的代理
包含在内。然而,代理
类型看起来好多了:
全部量化代理类型代理人a。代理一个
(基础库至今仍在使用),而不是 forall a。代理服务器a
本身很有趣,因为线程中的其他电子邮件建议那里可能有多个代理
在Haskell周围浮动的实例生态系统。正如评论中提到的那样, Kmett的加标签的图书馆在2010年6月已将其恢复。。f (undefined :: T)
Kiselyov and Shan even used this approach in their classic paper on class-based reflection that inspired the reflection
package. They excused the obvious ugliness by noting that the bogus value is never inspected. And an only slightly less ugly incarnation appears in Data.Bits.finiteBitSize
, which takes a value it ignores to get its type.
Then someone figured out the proxy idiom, and everything changed. Now we always see the much more satisfactory
f (Proxy :: Proxy T)
(in standard code—GHC type application is another story).
Who figured it out? Did this first appear in code somewhere, or a paper?
A fantastic question. TypeLevelReasoning, an early GHC proposal from April 2013, references the libraries
thread "Proxy, new Typeable, and type-level equality" (original poster Richard Eisenberg, the driving force behind many of the recent dependent Haskell work). That thread references another libraries
thread "Proxy and new-typeable" (original poster Shachaf Ben-Kiki), which was started in response to a patch from the new-typeable
branch. It is difficult to find a record of old branch names and which commits they pointed at, but commit 3d53407 by José Pedro Magalhães seems to be the squashed version of that branch. Indeed it appears to be the first commit landing in GHC to introduce a data Proxy t = Proxy
type. Eisenberg would later move that type to Data.Proxy
in commit 01aa22b in February 2013. The final design of Proxy
seems to be collective synthesis of ideas from many people. However, we can find academic references to Proxy
in Magalhães' work, such as his presentation "The right Kind of Generic Programming" (October 2012) and his blog post "Coming soon in GHC HEAD: poly-kinded Typeable" (November 2012). We can probably attribute the inclusion of Proxy
in base to him.
However, the idea of a Proxy
type seems much older:
"Giving Haskell a promotion" by Yorgey, Cretin, SPJ (October 2011)
"Scrap your boilerplate with class" by Lammel, Jones (ICFP 2005)
It is here that my Google searches turn up dry. I cannot seem to find an antecedent to that 2005 paper.
Coda: Shachaf's proposal in that thread, of universally quantifying the proxy type by using forall proxy a. proxy a
(which the base libraries still use to this day) instead of forall a. Proxy a
is itself interesting, as that and other emails in the thread suggest there at one point might have been multiple instances of Proxy
floating around the Haskell ecosystem. As mentioned in the comments, Kmett's tagged library had it back in June 2010.
这篇关于谁发明了代理传球和什么时候?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!