BTW, here's a non-contrived example.  It's pretty easy to come up with examples when you try to use type classes instead of a proper module system.

Here we have expressions parametrized over how identifiers and literals are represented.  First a simple instance, and then one where all the types are parametrized over the string representation.  These are the plug-and-play type of things I'd like to be able to do.

class IsExpr expr id lit | expr -> id lit where
    eId :: id -> expr
    eLit :: lit -> expr
    eApply :: expr -> expr -> expr

data SimpleExpr = SId Char | SLit Int | SApply SimpleExpr SimpleExpr

instance IsExpr SimpleExpr Char Int where
    eId = SId
    eLit = SLit
    eApply = SApply

data FancyExpr str = FId (Id str) | FLit (Lit str) | FApply (FancyExpr str) (FancyExpr str)

data Id str = Id str
data Lit str = LString str | LInt Int

instance IsExpr (FancyExpr str) (Id str) (Lit str) where
    eId = FId
    eLit = FLit
    eApply = FApply


On Fri, Apr 18, 2008 at 9:26 AM, Martin Sulzmann <martin.sulzmann@gmail.com> wrote:
Lennart Augustsson wrote:
To reuse a favorite word, I think that any implementation that distinguishes 'a -> b, a -> c' from 'a -> b c' is broken. :)
It does not implement FD, but something else.  Maybe this something else is useful, but if one of the forms is strictly more powerful than the other then I don't see why you would ever want the less powerful one.

Do you have any good examples, besides the contrived one


class D a b c | a -> b c

instance D a b b => D [a] [b] [b]

where we want to have the more powerful form of multi-range FDs?

Fixing the problem who mention is easy. After all, we know how to derive
improvement for multi-range FDs. But it seems harder to find agreement whether
multi-range FDs are short-hands for single-range FDs, or
certain single-range FDs, eg a -> b and a -> c, are shorthands for more powerful
multi-range FDs a -> b c.
I clearly prefer the latter, ie have a more powerful form of FDs.

Martin