Overloaded record fields

Malcolm Wallace malcolm.wallace at me.com
Fri Jun 28 14:32:40 CEST 2013

On 28 Jun 2013, at 12:16, AntC wrote:

> Thanks Simon, I'm a little puzzled what your worry is.
>> 	f r b = r.foo && b

>> With dot-notation baked in (non-orthogonally), f would get the type
>> 	f :: (r { foo::Bool }) => r -> Bool -> Bool
>> With the orthogonal proposal, f is equivalent to
>> 	f r b = foo r && b

I believe Simon's point is that, if dot is special, we can infer the "Has" type above, even if the compiler is not currently aware of any actual record types that contain a "foo" field.  If dot is not special, then there *must* be some record containing "foo" already in scope, otherwise you cannot infer that type - you would get a "name not in scope" error instead.

The former case, where you can use a selector for a record that is not even defined yet, leads to good library separation.  The latter case couples somewhat-polymorphic record selectors to actual definitions.

Unless you require the type signature to be explicit, instead of inferred.

(For the record, I deeply dislike making dot special, so I would personally go for requiring the explicit type signature in this situation.)


More information about the Glasgow-haskell-users mailing list