On 2 May 2015 04:28, "Matt Oliveri" <atma...@gmail.com> wrote: > But what enforces the coherence? And why doesn't it rule out the > ability to explicitly pass other instances? My understanding is that > coherence implies that the program can use only one instance of a > given typeclass for a given argument vector. So it makes no sense to > pass an instance explicitly; there's only one choice. If there are > multiple choices, you don't have coherence. Please, someone correct me > if I understood it wrong; I am new to typeclasses.
Multiple choices do not matter at the site of definition. All that matters is that resolution finds a single match. I agree with the video that Scala's scoping rules make it hard to understand instance wins when multiple could match. > I'm afraid the rest of your email didn't clarify anything for me. We > both understand the advantage of giving up coherence. But you seem to > underestimate the disadvantages. I don't see how you expect to recover > the guarantees of coherence while allowing instances to be passed > explicitly. This all comes back to passing first class functions. You see nothing wrong with passing a first class function. How about a record containing several functions, still fine right. Each value of the record type can pass different implementations of the functions as long as they all have the same type (or the record can have type parameters). So passing a record is like explicit dictionary passing, and dictionary passing is the method used to implement type classes. In my suggestion, the record type declaration creates a matching type-class (or it can be viewed as both things simultaneously) but record values are not automatically instances of that class, they are simply record values. Only when you promote them to type-classes with the 'use' declaration, do they function as type class instances. Type class instances must be globally coherent exactly as in Haskell. Keean.
_______________________________________________ bitc-dev mailing list bitc-dev@coyotos.org http://www.coyotos.org/mailman/listinfo/bitc-dev