goldfirere / units

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

Consider introducing `:#` to control `Show` instances #14

Closed goldfirere closed 10 years ago

goldfirere commented 10 years ago

nushio3 says:

I'm thinking of introducing a type constructor

data q :# u
instance Show (q:#u) where show (q:#u) = showIn q u

which is essentially a tuple of a quantity and a unit, designating that we want to associate the quantity with the specified unit.

(Copied from #12, where this is less relevant.)

goldfirere commented 10 years ago

Upon further thought, this seems like a bad idea. If :# is a datatype as above, then it is not a Qu, wreaking terrible havoc. If it's a type function, then what does it evaluate to? It has to be a Qu, and then we don't have the ability to change the Show instance. Yuck.

Instead, I propose moving showIn out from the Data.Metrology.Show module, so that users can use showIn but define their own Show instances for their quantities.

Leaving this ticket open as a reminder to do that refactoring.