Haskell Foldable Wats

Herbert Valerio Riedel hvr at gnu.org
Thu Feb 25 10:18:25 UTC 2016


On 2016-02-25 at 10:21:20 +0100, Daniel Trstenjak wrote:
> What was the design decision behind orphans? Why were they considered
> a good idea?

In Haskell 1.2 there was a so-called "C-T Rule" which was
relaxed for Haskell 1.3 [1]:

| C-T Rule relaxation
|  
| The C-T rule restricts the placement of instance declarations to the
| module containing either the class or data type definition associated
| with an instance. This is unnecessarily restrictive and will be relaxed
| in Haskell 1.3. The new restriction will be that no more than one
| instance for a given class - datatype pair is allowed in a
| program. (Sadly, there's little hope of detecting violations of this
| rule before link time.)
|  
| The visibility of instance declarations presents a problem. Unlike
| classes or types, instances cannot be mentioned explicitly in export
| lists. Instead of changing the syntax of the export list, we have
| adopted a simple rule: all instances are exported regardless of the
| export list. All imports bring in the full set of instances from the
| imported module. An instance is in scope when a chainof import
| statements leads to the module defining the instance.


With some luck you may be able to find the discussions leading up to
that decision in old email archives.


Maybe relevant to this discussion: the rejected paper "Controlling the
scope of instances in Haskell" submitted for the 2011 Haskell Symposium
together with the rejecting referee reports[2]



 [1]: https://www.haskell.org/definition/from12to13.html

 [2]: https://mail.haskell.org/pipermail/ghc-devs/2014-October/006876.html


More information about the Libraries mailing list