Dimensional analysis with fundeps

Andrew Kennedy akenn@microsoft.com
Wed, 11 Apr 2001 08:39:48 -0700


You shouldn't need rational exponents to take square roots as long as no
*ground* type requires them. If polymorphism over units were primitive,
then
we'd have something like

  sqrt :: Real (u.u) -> Real u

for a fixed numeric type Real that's parameterized over its units. (BTW,
it's
not possible to define such a function in the language using, say, only
standard=20
arithmetic operators and comparison; you have to build it in instead).=20

In your encoding, is the following a valid type?

  sqrt :: (Num rep, Add kg kg kg', Add m m m', Add s s s') =3D>=20
    Dimensioned kg' m' s' rep -> Dimensioned kg m s rep

Or have I misunderstood multi-parameter classes with functional
dependencies?
- Andrew.

> -----Original Message-----
> From: anatoli [mailto:anatoli@yahoo.com]=20
> Sent: Monday, April 09, 2001 5:37 PM
> To: haskell@haskell.org
> Subject: Dimensional analysis with fundeps
>
> There is a couple of things :) left to make this usable:
>=20
...
>=20
> 2) Make it work with rational (not just integer) exponents,
>    so one can take square roots and the like.
>    (Can one do GCD in this style, without resorting to
>    undecidable and/or overlapping instances?);
>=20