[m-dev.] functional dependencies syntax
Ralph Becket
rafe at cs.mu.OZ.AU
Tue Apr 5 17:24:17 AEST 2005
Mark Brown, Tuesday, 5 April 2005:
>
> There has been some discussion in the office, which I shall summarise here.
> Two main suggestions were made, both of which I am inclined to agree with.
>
> Suggestion 1:
>
> Use '->'/2 as the top-level operator for a functional dependency, and use
> ','/2 as the operator to construct sets of type variables in the domain
> and range of the FD.
>
> Some example FDs with this syntax:
>
> (A -> B)
> (A, B, C -> D)
> (A, B -> C, D, E)
>
> The drawback of this is that there is no obvious way to specify an empty
> domain or range.
I find it hard to imagine what such a thing would even mean.
I like this suggestion.
> Suggestion 2:
>
> Rather than introduce a new keyword to precede the FDs (I used "given" in
> my earlier example), make '->'/2 into a special builtin typeclass with the
> semantics of FDs and place any FDs in the set of constraints on your
> typeclass declaration.
>
> For example:
>
> :- typeclass container(C, E) <= (C -> E) where ...
> :- typeclass foo(A, B) <= (bar(A, B), (A -> B)) where ...
> :- typeclass baz(A, B, C) <= (quux(A), (A, B -> C), quuux(B, C)).
>
> The FDs would be able to appear anywhere in the set of constraints.
This is also a good suggestion.
> An alternative is that FDs must be at the start of the list of constraints.
> Another alternative is that they must be at the end of the list.
These seem needlessly restrictive to me.
> - This would preclude the use of '->'/2 as the name of a user
> defined typeclass, unless we provide some way of escaping the
> special meaning of this name in typeclass declarations.
This is not a significant loss.
> - There is a slight lack of orthogonality here because, unlike
> ordinary constraints, FDs can only appear on typeclass declarations.
> They can't appear on instances, preds, funcs, or existentially
> quantified types.
FDs are a property of the type class, not of those other things. So
this is fine.
-- Ralph
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list