[Haskell] Empty instance declaration

Isaac Dupree isaacdupree at charter.net
Fri Dec 28 10:37:48 EST 2007


David Roundy wrote:
> The trouble, of course, is that classes could have rather complicated
> "minimum instance" requirements.  Still, if someone came up with a
> decent syntax such as (but better than)
> 
> class Foo f where
>    foo :: f
>    foo = bar
>    bar :: f
>    bar = foo
>   requiring ( foo || bar )
> 
> it would be very nice.  The trouble, of course, is deciding how
> expressive to make the requirements.

probably a pragma, since it only affects warnings.  And it seems like 
each class only has a finite number of functions, so a Boolean 
expression should be able to express the full range of possibilities 
with ( || , && , not , True , False ); and combinations that are 
complicated to express with those, aren't very common, due to the 
structure of the problem.

 > class Foo f where
 >    {-# MINIMAL_INSTANCE foo || bar #-}
 >    foo :: f
 >    foo = bar
 >    bar :: f
 >    bar = foo

I wonder whether it would be safe for the compiler to infer simply by 
the default methods mentioning each other in a cycle.  It might miss 
some cases when (probably involving laziness) the default methods 
actually terminate and form an intended set of implemention, and warn 
when it shouldn't... which is bad, but does that ever happen?

Isaac


More information about the Haskell mailing list