goldfirere / units

The home of the units Haskell package
94 stars 19 forks source link

More general Eq and Ord instances #25

Closed mtolly closed 10 years ago

mtolly commented 10 years ago

Currently Eq and Ord instances are only defined for dimensionless quantities:

deriving instance Eq n => Eq (Qu '[] l n)
deriving instance Ord n => Ord (Qu '[] l n)

I'm wondering why this can't be changed to quantities of any dimension:

deriving instance Eq n => Eq (Qu d l n)
deriving instance Ord n => Ord (Qu d l n)

These operators would still be less general than |==|, |<|, etc., because they don't do normalization with @~. But they'd be quite useful nevertheless, when using other functions that expect an Eq or Ord instance.

As far as I can tell this should be perfectly safe since the dimensions of the two compared quantities will be exactly the same.

goldfirere commented 10 years ago

Good point. Will do shortly.