<br>
But, the Has constraints MUST exist, in full glory, in the constraint<br>
solver. The only question is whether you can *abstract* over them.<br>
Imagine having a Num class that you could not abstract over. So you<br>
could write<br>
<br>
k1 x = x + x :: Float<br>
k2 x = x + x :: Integer<br>
k3 x = x + x :: Int<br>
<br>
using the same &#39;+&#39; every time, which generates a Num constraint. The<br>
type signature fixes the type to Float, Integer, Int respectively, and<br>
tells you which &#39;+&#39; to use. And that is exactly what ML does!<br>
<br>
But Haskell doesn&#39;t. The Coolest Thing about Haskell is that you get<br>
to *abstract* over those Num constraints, so you can write<br>
<br>
k :: Num a =&gt; a -&gt; a<br>
k x = x + x<br>
<br>
and now it works over *any* Num type.<br>
<br>
On reflection, it would be absurd not to do ths same thing for Has<br>
constraints. If we are forced to have Has constraints internally, it<br>
woudl be criminal not to abstract over them. And that is precisely<br>
what SORF is.<br></blockquote><div><br></div><div>So I understand that internally a Has constraint is great for resolving the type.</div><div>What is the use case for having the Has abstraction externally exposed?</div><div>

<br></div><div>I think there is a great temptation for this because we would have a functionality we can point to that has some kind of extensible record capability.</div><div><br></div><div>But I believe the Has abstraction to be a form of weak-typing more so than a form of extensibility. Just because 2 records have a field with the same name, even with the same type in no way signifies they are related. Instead we need a formal contract for such a relation. We already have that in type classes, and they can already be used for this very capability in a more type-safe way.</div>

<div><br></div><div>Let me give an example use case that we would be tempted to use this for: database record projections. Given a record representing a row of a database table</div><div><br></div><div> data Row = Row { smallName :: String, largeVideo :: ByteString }</div>

<div><br></div><div>We may have occasions in which we just use a subset of the database/record fields.</div><div><br></div><div> display :: Row -&gt; String</div><div> display r = smallName r</div><div><br></div><div>

We can gain efficiency by just selecting the fields we need from the database (smallName). But now I need to re-factor all my Haskell code to have a projection of the original record with just the needed fields. I could try to make a sum type with projections, but then I need to pattern match on them. </div>

<div><br></div><div>This seems like a great use case for a generic Has abstraction, but that broadens the types allowed to outside of just Record. Instead what I really need is a more specific Has abstraction. I want to write just:</div>

<div><br></div><div><div> display :: RowSmallName r =&gt; r -&gt; String</div></div><div><br></div><div>So instead I should use type classes, but not something generic for all possible records, something for all possible Row projections. I do have to name the different Row types, and deal with re-factoring when field usage changes, but at least I have type-safety.</div>

<div><br></div><div>i would like to avoid re-factoring and have the compiler to generate this constraint automatically based on what fields are required in the function.</div><div><br></div><div> display :: RowProjection &quot;smallName&quot; -&gt; String</div>

<div><br></div><div><br></div><div>Ideally this information is propogated back to the point where I create the records. Using the Persistent library:</div><div><br></div><div> records &lt;- selectList [RecordSmallName .== &quot;Bob&quot;] []</div>

<div><br></div><div>Persistent uses Template Haskell to automatically define serializing to and from records, including the full database query projection. We could generate instances for the different available record projections automatically ahead of time. With this kind of system, we would have an amazing feature of automatic database projection for queries. But maybe this kind of system would end up with horrible error messages or have details that are very difficult to work out.</div>

<div><br></div><div>My point is that Has abstractions are weak types and that likely we should be searching for something stronger or using type classes. If I am wrong then we should have convincing use cases outlined before we make this a goal of a records implementation, and still I don&#39;t see why it needs to be a blocking requirement if we are just trying to solve the basic records issue.</div>