[Haskell] Re: ANN: ListLike, a generic interface over list-like structures

John Goerzen jgoerzen at complete.org
Mon Sep 17 22:16:16 EDT 2007

On Monday 17 September 2007 6:14:57 pm Bas van Dijk wrote:
> On 9/17/07, John Goerzen <jgoerzen at complete.org> wrote:
> > That does show one annoying property of typeclasses: instances too
> > easily appear and are impossible to replace.
> The problem would be solved if it was possible to explicitly import
> and export instance declarations.
> I asked this before [1] but I actually almost never had the need for
> it. But then I'm not a library writer...
> It would be nice to know how serious this problem is. Are there other
> people that have had a similar problem?

I have also been annoyed by this with instances of Read and Show.  In several 
situations, I preferred to have my own formatter or parser, and it would 
have been most convenient to do so as a different instance of Read or Show.

However, I would not say that it has ever been a serious problem.  
Workarounds exist, such as creating new typeclasses or simply using 
dedicated functions.  It would be nice if there were some syntax where you 
could say something along the lines of

instance (Show a, a /= Integer) => MyShow a where
   myshow = show

instance MyShow Integer where
   myshow = customshow

for example.

-- John

More information about the Haskell mailing list