Re: Dimensional analysis with fundeps (some physics comments)

I'm cross-posting this to the Libraries list... At 2001-04-10 18:02, Fergus Henderson wrote:
Still, the need to insert explicit `toUnits' is annoying, and it would be nice to have a system where every number was already a dimensionless unit.
That's easy: -- type Unit rep = Dimensioned Zero Zero Zero rep; instance (Real a) => Real (Unit a) where { -- put instances here }; -- Of course you'll have to appropriately declare superclasses of Real, such as Num, Ord, Show, Eq etc. -- Ashley Yakeley, Seattle WA

Excuse me for playing referee here, as I am looking at this discussion from a very abstract level, as I am a beginning functional-logic programmer. But my question (primarily for Fergus) is: "has Ashley shown in her example a means of automating a toUnits imperative in Haskell that must be done explicitly in Mercury?" If so, then we have the start of the Haskell-Mercury comparison document which shows an advantage of Haskell over Mercury.
I'm cross-posting this to the Libraries list...
At 2001-04-10 18:02, Fergus Henderson wrote:
Still, the need to insert explicit `toUnits' is annoying, and it would be nice to have a system where every number was already a dimensionless unit.
That's easy:
-- type Unit rep = Dimensioned Zero Zero Zero rep;
instance (Real a) => Real (Unit a) where { -- put instances here }; --
Of course you'll have to appropriately declare superclasses of Real, such as Num, Ord, Show, Eq etc.
-- Ashley Yakeley, Seattle WA
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 01-May-2001, Terrence Brannon
my question (primarily for Fergus) is: "has Ashley shown in her example a means of automating a toUnits imperative in Haskell that must be done explicitly in Mercury?"
Yes. In Haskell, there's some syntactic sugar attached to every numeric
literal: "123" is defined to mean "fromInteger 123", where "fromInteger"
is an overloaded (class member) function defined in the standard Prelude.
In Mercury, if you want "fromInteger" or "toUnit", then you need
to write it explicitly.
--
Fergus Henderson
participants (3)
-
Ashley Yakeley
-
Fergus Henderson
-
Terrence Brannon