CC: Functional dependencies question
Mon, 12 May 2003 20:55:55 -0700 (PDT)

>         hbar :: (Mult Energy Time t) => t
>         hbar = PhysicalUnit 6.62606876e-34

But what if we add to our library
	joule::Energy = PhysicalUnit 1.0
	cal::Energy = PhysicalUnit 4.8
	second::Time = PhysicalUnit 1.0
	nanosec::Time = PhysicalUnit 1.0e-9

scalarm:: Double -> (PhysicalUnit a1 b1 c1) -> (PhysicalUnit a1 b1 c1)
x `scalarm` (PhysicalUnit y) = PhysicalUnit $ x * y

then the user can write
	hbar = 6.62606876e-34 `scalarm` (joule `mult` second)

	hbar = 6.62606876e-25 `scalarm` (joule `mult` nanosec)
	hbar = (6.62606876e-25/4.8) `scalarm` (cal `mult` nanosec)

Can't we? Or I'm missing something? GHC seems happy.

We can probably define in the library

transf:: (PhysicalUnit a1 b1 c1) -> (PhysicalUnit a1 b1 c1) -> Double
transf (PhysicalUnit x) (PhysicalUnit y) = x/y

and write

   hbar = (6.62606876e-25/(cal `transf` joule)) `scalarm` (cal `mult` nanosec)

Just for the record: yet another way to introduce negative numbers is
through an explicit constructor Neg. For example:
(sorry, the code uses C++ templates. The idea is just the same
however: a mere Prolog in a more verbose notation).  The above example
demonstrates division of signed Peano numbers. The Neg constructor
becomes quite handy then.