[Haskell-cafe] Functional dependencies and Peano numbers
wren ng thornton
wren at freegeek.org
Fri Jul 9 22:43:02 EDT 2010
Brandon S Allbery KF8NH wrote:
> On 7/6/10 15:37 , Oscar Finnsson wrote:
>> but can they also be on a form similar to
>>
>>> a b c d e f g h| b c -> d e f | b d g -> h
>> (i.e. d,e,f are decided by the b,c-combination while h is decided by
>> the b,d,g-combination)?
>
> I think the answer to this is "yes, but if you have an MPTC with 8
> parameters then you desperately need to refactor".
Yes, you can add multiple dependencies. The syntax is to use , after the
first |.
While having eight parameters is surely a desperate need for
refactoring, there are times when you'd want multiple dependencies. For
example, you can say
class F a b | a -> b, b -> a where...
to express a bijective function on types (that is, for every pair of A
and B, if you know one of them then you know what the other must be
uniquely).
--
Live well,
~wren
More information about the Haskell-Cafe
mailing list