[Haskell-cafe] Fwd: Increasing Haskell modularity
gesh at gesh.uni.cx
Wed Oct 1 21:44:25 UTC 2014
On 10/1/2014 10:49 PM, David Menendez wrote:
> How is that neither here nor there? Haskell says that types belong to
> classes, and each (type) instance of a class has a specific
> implementation. The fact that GHC implements this using dictionaries is
> irrelevant. It’s perfectly valid to implement type classes with partial
> evaluation, or matching on type parameters, or even C++-style templates.
How is this point relevant? As far as I understand typeclasses enjoy
three properties: confluence, coherence and global uniqueness.
These are defined as follows:
* Confluence: Constraint-solving always terminates with the same sets
of constraints on terms.
* Coherence: The same instance is always chosen for terms.
* Global uniqueness: For any type and typeclass, there exists at most
one instance of the typeclass for the type.
What I suggested was to weaken global uniqueness to local uniqueness,
* Local uniqueness: For any type and typeclass, in any scope there
exists at most one instance of the typeclass for
And a scope is a set of parallel bindings, introduced by a module
declaration, let expression or where clause.
Since this only affects global uniqueness, I fail to see how concerns
about coherence being lost are relevant.
> In other words: no, coherency is not preserved. You can’t change the
> semantics of classes and then say that programs built around the old
> semantics were wrong all along.
Correct, although that's not what I said. I just said that a case could
be made for saying the design of programs around global uniqueness was
poorly thought out. I admit that these changes will require people to
redesign such programs. I'm not convinced this is a bad thing.
I am sorry for not being clearer to begin with.
More information about the Haskell-Cafe