[Haskell-cafe] The instability of Haskell libraries

John Goerzen jgoerzen at complete.org
Mon Apr 26 09:33:09 EDT 2010

On 04/25/2010 03:47 PM, Ivan Lazar Miljenovic wrote:
> So you recommend having packages specifically for instances?
> My main problem with this is if you want a custom variant of that
> instance.  Let's take FGL graphs for example with instances for
> QuickCheck's Arbitrary class.  Maybe you want arbitrary graphs that are
> simple, or maybe multiple edges are fine.  Even when considering
> Arbitrary instances for something like String you may wish to have a
> custom variant that makes sense for what you're testing.
> My conclusion: it is not possible to have hard-and-fast conclusions for
> things like this :p

I'm inclined to agree.  As an example, there is the convertible library. 
  It grew out of the need to make an easy way to map Haskell to database 
types in HDBC, and these days is a more general way to convert from one 
type to another.  I provide a bunch of Convertible instances, but they 
are in separate modules, and thus can be omitted if a person doesn't 
want the instances.  As an example: what's the correct way to convert a 
Double to an Integer?  As an example, Prelude defines at least 4: 
ceiling, floor, truncate, and round.

Now, in a certain sense, Convertible is designed for people that don't 
care which is used.  (And yes, that is a perfectly valid answer in some 
cases.)  But if you want your own, you can simply not import the numeric 
Convertible instances.

It would, however, be nice if the language allowed you to override 
default instances with the code in your own package.

-- John

More information about the Haskell-Cafe mailing list