
Hi All, Is there a good way to easily convert between units? For example, let's say I have a data type: data Volumes = Teaspoon | Tablespoon | Slice | FluidOunces ... and I want to define an infix function '<+>', which adds together amounts of food: (1, Slice, cake) <+> (1, Volume Tablespoon, sugar) <+> (32, Volume FluidOunces, almondMilk) Which would return: (3200, Teaspoons) What is the most efficient way to define equivalency/conversion between these measures? I remember an interesting method for celsius-farenheit conversion in Higher-Order Perl, using function composition, but that was between only 2 units. I'd like something where I don't have to provide n^2 definitions. Thank you! Tom
participants (1)
-
Tom Murphy