<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I want to echo Edward's statement, and support the argument that the lack of type classes is an enormous limitation in Agda.<div><br></div><div>It turns out that type classes are also extremely useful for proof developments (as opposed to "just" programs) in dependently typed languages, and Coq users have already seen lots of the benefits of this. Although Coq's type class mechanism is much less principled than Haskell's, in that it is extremely easy to get it to diverge and difficult to reason about. This is because they plugged all of type class resolution into an eauto hint database. One can hope to do much better.</div><div><br></div><div>I don't see how you could hope to "generalize" the type class mechanism by writing type-level functions inside the logic of Agda. Type class resolution is about *static* recursive term construction, and as your static universe of types grows, so must your instance resolution be open to new mappings. Sure, there is some hope that we could get a closed, recursive construction of, say, Eq instances, as an agda-level function using universes and generic programming. But there will be classes for which one doesn't want to define all instances for in one go.</div><div><br></div><div>Type classes give you added expressivity (recursive term construction), and this expressiveness comes necessarily from the fact that resolution happens statically, and outside the logic. Yes, adding type classes to your languages makes it a little more complicated, but it never touches the core type theory, and the simple version (basic recursive search) is really not *that* crazy. At least not any crazier than instance arguments, which are much less principled than type classes (find an arbitrary term in scope with the right type), and doomed to forever be inefficient with their current semantics.</div><div><br></div><div>So I restate the question: what is the real barrier to adding type classes to Agda? Do you believe that in the end we don't need them, or that they can be generalized by Agda functions? Then us advocates of type classes should provide more compelling examples of their expressive power. Do you believe it adds too much complexity to the language? Then us advocates should propose a non-obtrusive resolution system that cleanly elaborates to core, similar in spirit to the design of instance arguments. If not these… what is the barrier?</div><div><br></div><div>Best,</div><div>David</div><div><br><div><div><div>On Oct 2, 2013, at 3:28 PM, Edward Kmett <<a href="mailto:ekmett@gmail.com">ekmett@gmail.com</a>> wrote:</div><br><blockquote type="cite"><span style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none; ">I just want to mention as a data point the lack of recursive instance search is one of the things that prevents me from actively writing more Agda code today. Almost nothing I want to say is first-order enough that it can infer any arguments I actually want to use, and libraries like lens can't usefully be ported to Agda without it.</span><br style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><br style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none; ">I would love to have a more principled story though, so I understand the current motivations, they just keep me stuck waiting in the wings. ;)</span><br style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><br style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none; ">-Edward</span><br style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "></blockquote></div><br></div></div></body></html>