[Haskell-cafe] Fundeps and overlapping instances
AntC
anthony_clayden at clear.net.nz
Fri Jun 1 03:46:32 CEST 2012
Iavor Diatchki <iavor.diatchki <at> gmail.com> writes:
>
> Hello,
>
> the notion of a functional dependency is well established, and it was used
well before it was introduced to Haskell (for example, take a look
at http://en.wikipedia.org/wiki/Functional_dependency). So I'd be weary to
redefine it lightly.
Yes functional dependency is well established in relational algebra (set
theory actually) -- it's about values in attributes. But there's nothing
corresponding to typevars (I suppose you might call those patterns of values);
there's nothing like overlaps.
Perhaps instances with Fundeps should only use H98-style arguments? Perhaps we
should disallow overlaps with Fundeps (as Hugs does pretty-much)?
I can only understand tricky Fundeps by mentally translating them into type-
level functions (and I was doing that before type families/associated types
came along).
class C a b | a -> b ===> type family CF a
instance C a b ===> type instance CF a = b
And that type instance is rejected because `b' is not in scope.
Currently there are all sorts of tricks in instance declarations with overlaps
and Fundeps, to achieve the effect of type-level functions. You do end up with
instance arguments being all typevars, because the instance selection logic is
really going on inside the constraints, with type-level 'helper functions'.
Some of Oleg's instances are awesome (and almost impenetrable -- the TTypeable
code is a tour de force).
It's all so *dys-functional* (IMO).
My take is that we should abandon Fundeps, and concentrate on introducing
overlaps into type functions in a controlled way (what I've called 'dis-
overlapped overlaps'.)
AntC
More information about the Haskell-Cafe
mailing list