3 ms·
This is not idiomatic code. Briefly: data Inches = MkInches Double deriving (Eq,Show) There is newtype for this. (MkInches u) \+/ (MkInches v) = MkIn
by BasDirks 12y ago
This is not idiomatic code. Briefly:
data Inches = MkInches Double deriving (Eq,Show)
There is newtype for this.
(MkInches u) \+/ (MkInches v) = MkInches ( u + v )
First two pairs of parens are redundant.
from_inches_to_cm vin =
MkCm (vin_as_pure_double * 2.54)
where
(MkInches vin_as_pure_double) = vin
Surely you want:
inchToCm (MkInches x) = MkCm (x * 2.54)
In Haskell we use camelCase.
Besides these fairly trivial mistakes there are simply better approaches for dealing with units.