![]() ![]() This property is a very convenient one when building abstractions like sets. Languages with local typeĬlass instances such as Scala generally do not have this property, but in Haskell, we find Instance resolution for a given type class. So, what is it that people often refer to when they compare Scala type classes to Haskell type classes? I am going to refer to this as global uniqueness of instances, defining to say: in a fully compiled program, for any type, there is at most one Why couldĭiffering typing derivations result in different dynamic semantics? TheĪnswer is that context reduction, which picks out type class instances,Įlaborates into concrete choices of dictionaries in the generated code.Ĭonfluence is a prerequisite for coherence, since oneĬan hardly talk about the dynamic semantics of a program that doesn't Resulting program that has the same dynamic semantics. This property states thatĮvery different valid typing derivation of a program leads to a In other words, confluence says that we won't conclude that a programĭoesn't type check just because we swapped in a different constraintĬonfluence's closely related twin is coherence (defined in the paper "TypeĬlasses: exploring the design space"). Of constraints that must be satisfied for any given use of a type class. Confluence is a property that comes from term-rewriting: a set of instances is confluent if, no matter what orderĬonstraint solving is performed, GHC will terminate with a canonical set Let's start with the definitions of the two terms. So in this blog post, I want to settle the distinction, and propose a new term, "global uniqueness of instances" for the property which people have been colloquially referred to as confluence and coherence. While I was doing background reading, I was flummoxed to discover widespread misuse of the terms "confluence" and "coherence" with respect to type classes. The discussion here is closely motivated by the work we are doing at MSRC to support type classes in Backpack. Today, I'd like to talk about some of the core design principles behind type classes, a wildly successful feature in Haskell.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |