packages with orphaned instances only

Johan Tibell johan.tibell at gmail.com
Mon Jan 10 17:37:44 CET 2011


On Fri, Jan 7, 2011 at 11:22 AM, Christian Maeder
<Christian.Maeder at dfki.de> wrote:
> Hi,
>
> referring to previous messages about QuickCheck and Johan's proposal
> about moving instances I wonder how many of us have created obviously
> orphaned "Arbitrary" instances for container data types?
>
> Maybe indeed separate packages with (orphaned) instances only should be
> created for re-use. I haven't seen such packages on hackage, yet. And
> maybe such packages should be clearly recognizable.
>
> So is this a bad idea?

It's often not possible to define instances separately, as you often
needs to access data constructors internal to the module that defines
them. This is the case for the containers package. It's largely
accidental that you can define e.g. an NFData instance for Data.Map
outside the module and the instances are usually less efficient if
defined outside the module [1].

1. You often end up converting the data type to another data type
(e.g. lists) that expose their data constructors and can thus be
'seq'ed.

Johan



More information about the Libraries mailing list